Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AHK网页元素按钮按下_Javascript_Html_Autohotkey - Fatal编程技术网

Javascript AHK网页元素按钮按下

Javascript AHK网页元素按钮按下,javascript,html,autohotkey,Javascript,Html,Autohotkey,我已经尝试了一段时间来理解如何让AHK按钮按下,不是通过图像或像素搜索,也不是通过坐标,而是通过web元素ID,这样它就可以在不同的PC上正常工作,而不会出现问题,并且更不容易出故障 我已确定按钮的web代码: <div class"rightButtonSection"> <button name="PierPropertiesContainer_componentnext_0" title="Next Page" class="button buttonLink" oncl

我已经尝试了一段时间来理解如何让AHK按钮按下,不是通过图像或像素搜索,也不是通过坐标,而是通过web元素ID,这样它就可以在不同的PC上正常工作,而不会出现问题,并且更不容易出故障

我已确定按钮的web代码:

<div class"rightButtonSection">
<button name="PierPropertiesContainer_componentnext_0" title="Next Page" class="button buttonLink" onclick"setKeys(event);__xee72onclick(this);" type="button">Next</button>
</div>
可悲的是,这仍然毫无作用,但我感觉它越来越近了

编辑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.

看看@Michael_Curry的评论。您需要创建一个包含web浏览器对象(Internet Explorer)的AHK对象。下面是一个创建脚本的简单脚本:

wb := ComObjCreate("InternetExplorer.Application")  ;// Create an IE object
wb.Visible := true                                  ;// Make the IE object visible
wb.Navigate("www.AutoHotkey.com")                   ;// Navigate to a webpage
然后,您的代码按如下方式工作:

wb.document.getElementById("button")
按评论编辑:

如果需要找到一个已打开的IE选项卡用作wb对象,则将第一行替换为:

IEGet("The name of the IE tab you want to use")
并将以下IEGet函数(从链接)添加到脚本中:

IEGet(name="") {
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
   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
}
根据OP的合理尝试进行编辑

你正在到达那里。你需要在IE标签名称中加引号,并且可能有助于使用选择器(但这是另一个问题)。尝试:


Hth,

getElementbyID在这种情况下不起作用,因为对象中没有名为“ID”的元素。您必须通过另一个选择器“抓取”它——很可能是类或类型。可悲的是,我和你一样,都是使用javascript的对象,所以除了尝试getElementsbyClassName或循环遍历所有这种类型的对象,找到它在页面上的编号并以这种方式选择之外,我没有其他答案。祝你好运

只是一个链接,所以不是答案:希望这有帮助!“我从来没有在网上找到一本对AHK有帮助的指南”?哇,这是相当容易搜索和获得上述链接。(提示,这是这个搜索中的第四个:ahk getelementbyid)在一些或多或少都有它的SO链接之后。这是朝着正确方向迈出的一步,干杯!你很接近。您需要IE选项卡的名称才能传递到IEGet。再次看到编辑,马克回答,因为至少我们走了这么远。公平地说,在选择ElementID函数中的元素时,您可能会遇到一个新问题。但同样,请看下面。你是对的,我确实需要帮助选择它!至少我有点了解现在发生的事情。tack kompisAh好的,现在当我尝试这个ComObjCreate时,它为internet explorer创建了一个新窗口。那不是我想要的。窗户已经打开了。我不能在家里复制,但它似乎发生在工作中。。。我不知道那里发生了什么。这可能与IE中运行documentum有关吗?对不起,我有点不知所措,不知道该找什么看看那个链接。还描述了如何枚举打开的IE选项卡(使用Shell.Application对象),从而可以访问打开的IE选项卡,然后wb ahk对象可以引用打开的IE选项卡。我会把它作为一个编辑在一点。我已经编辑了进展后,但它仍然没有真正做什么。。。感觉我错过了一些简单的评论!!我最终放弃了,似乎如果Java即将问世,那么它就无法实现:(这种循环业务听起来可能会让人心神不宁……我们该怎么做呢?我会从ahk板上的这条线索开始,看看它是否有帮助。希望它能引导你走向正确的方向。如果你有任何成功,让我知道!哦,顺便说一句,我喜欢你的名字。这是最好的。
IEGet(name="") {
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
   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("IE tab name") ;// here put in the actual IE tab name in quotes
wb.Visible := true
wb.document.getElementById("PierPropertiesContainer_componentnext_0").click() ;// is button the ID? try the name or a different selector