简体   繁体   English

AutoIt单击IE中没有名称或ID的类的onClick Javascript按钮

[英]AutoIt Clicking a onClick Javascript button with no name or id only class in IE

Trying to script a button click on a button on the amazon website that looks like this: 尝试编写一个脚本脚本,然后单击亚马逊网站上的一个按钮,如下所示:

  <span class="action-go" onclick="MYO.JS.handle_action($(this).parent().find('.action option:selected').attr('value'),&#10;     $(this).parent().find('.action option:selected').attr('url'));">
          <input width="21" height="21" align="absmiddle" type="image" src="https://images-na.ssl-images-amazon.com/images/G/01/abis-ui/buttons/go._V187564664_.gif" border="0">
        </span>

<input width="21" height="21" align="absmiddle" type="image" src="https://images-na.ssl-images-amazon.com/images/G/01/abis-ui/buttons/go._V187564664_.gif" border="0">

This is what I have tried: 这是我尝试过的:

Func GetButtons()
    Local $oBtns = _IETagNameGetCollection($g_oIE, "span")
    For $oBtn In $oBtns
        If String($oBtn.classname) = "action-go" Then
            _IEAction($oBtn, "click")
        EndIf
        ExitLoop
Next
EndFunc

Solution that Worked 有效的解决方案

Func ClickButton()
$HWND = _IEPropertyGet($g_oIE, 'HWnd')
WinSetState($HWND, "", @SW_MAXIMIZE)
_IEAction($g_oIE,"visible")
_IELoadWait($g_oIE)
MouseClick($MOUSE_CLICK_LEFT, 290, 354, 2)
EndFunc   ;==>GetButtons

I don't have the time to script you a solution, but i can tell you how I would do it. 我没有时间为您编写解决方案的脚本,但是我可以告诉您我将如何做。 The trick is to not click on the button, but its position. 诀窍是不要单击按钮,而是单击其位置。 This only works if the GUI allways has the same proportionalities. 仅当GUI始终具有相同的比例时,这才有效。

  1. You detect the position of the window. 您检测到窗口的位置。 As long as it has a name this should work. 只要它具有名称,它就应该起作用。
  2. You detect the position of the button relative to the window, by useing AutoIt Window Info. 通过使用AutoIt窗口信息,您可以检测按钮相对于窗口的位置。
  3. You add both values and click on that position. 您将两个值相加,然后单击该位置。

You can click on a position by useing MouseClick . 您可以使用MouseClick单击某个职位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM