【发布时间】:2018-09-06 02:01:02
【问题描述】:
我一直在尝试了解如何让 AHK 按下按钮,而不是通过图像或像素搜索,或通过坐标,而是通过网络元素 ID,以便它可以在不同的 PC 上正常工作,没有问题,并且减少失败的可能性。
我已经确定了按钮的网页代码:
<div class"rightButtonSection">
<button name="PierPropertiesContainer_componentnext_0" title="Next Page" class="button buttonLink" onclick"setKeys(event);__xee72onclick(this);" type="button">Next</button>
</div>
我在这方面有点不知所措,而且我从来没有在网上找到对 AHK 有很大帮助的指南。
我认为这将与 document.getElementById("button") 有关,这是我目前所知道的。
如果您知道我接下来可以尝试什么或需要什么额外信息,请告诉我!
干杯
编辑:
根据感谢提供的链接和建议,我将其放在一起:
!q::
IEGet(name="") {
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame
Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft)? ?Internet Explorer$")
for wb in ComObjCreate("Shell.Application").Windows()
if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
return wb
}
wb := IEGet()
wb.Visible := true
wb.document.getElementById("button").click()
return
遗憾的是,这仍然没有任何作用,但我觉得它正在接近。
编辑2:
IEGET(name="") 位似乎正在工作,它将循环浏览所有打开的选项卡,看起来像。但是一旦它点击'return,wb'它就会挂在那里,所以问题一定是我识别标签名称......也许......
001: Return (3.37)
004: if name =
004: WinGetTitle,name,ahk_class IEFrame
005: name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft)? ?Internet Explorer$")
006: For wb, in ComObjCreate("Shell.Application").Windows() (0.09)
007: if wb.LocationName=Name && InStr(wb.FullName, "iexplore.exe")
008: Return,wb (4.82)
Press [F5] to refresh.
【问题讨论】:
-
只是一个链接,不是答案:autohotkey.com/board/topic/…希望这会有所帮助!
-
“我从来没有在网上找到对 AHK 有很大帮助的指南”?哇,这很容易搜索并获得上述链接。 . . (提示,这是此搜索中的第四个:ahk getelementbyid)在几个或多或少有它的 SO 链接之后。 . .
-
这是朝着正确方向迈出的一步,干杯老兄
-
是的!你很亲密。 . .您需要将 IE 选项卡的名称传递给 IEGet。再次查看编辑,并标记已回答,因为至少我们已经走到了这一步。公平地说,在 ElementID 函数中选择元素时,您可能会有一个新问题。但同样,请参见下文。
-
你说得对,我确实需要帮助来选择它!至少我有点明白现在发生了什么。大头针
标签: javascript html autohotkey