AutoHotKey单击JavaScript超链接

时间:2018-08-17 17:35:04

标签: javascript internet-explorer hyperlink autohotkey

我正在为我的公司开发AHK脚本,以在Internet Explorer界面上自动化一些乏味的手动处理。到目前为止,我已经能够创建IE实例,检测它是否存在/是否处于活动状态,并且我已经能够“ getElementById”填写文本字段,设置焦点,检索值并单击按钮。

但是对于最后一步,我无法一生搞清楚:该界面上有一些链接,这些链接不是指向另一个页面的简单URL超链接。其中之一上的“检查元素”显示以下HTML代码:

<span class="relatedLink" id="a_statusChangeLink" style="color: blue;" onclick="javascript:openWindowL('StatusChange.aspx?Co=ABC&Cov=001&Ident=AAAAA&Digest=0obCAhixDLtLZRc10og9fNmgf0F&PhzKUudf2spZF14')">Change Status</span>

这些链接并排存在,我已经能够使用该“ relatedLink”类来“ getElementsByClass”,并匹配具有.innerText =“ Change Status”的类。此类中的链接数组的索引是9。我的问题? .Click()属性不起作用。从HTML片段中可以看到,它触发了JS函数,该函数打开另一个窗口。我只尝试了“导航”到onclick链接,但是“摘要”参数是每次更改的键。仅供参考,这些链接仅在单击按钮后才会显示在页面上;他们以前不在那里。

我尝试过:AutoHotKey JavaScript Link 但这仍然归结为只是发送一个Click,而它什么也没做:/。我也尝试发送多次点击,但无济于事。

非常感谢您可以提供的任何建议:)。

我的相关代码:

IELoad(myWB)
{
    If !myWB
        Return False
    Loop
        Sleep, 50
    Until (myWb.Busy)
    Loop
        Sleep, 100
    Until (!myWB.Busy)
    Loop
        Sleep, 500
    Until (myWB.Document.Readystate = "Complete")
}
^t::    
    myWB := ComObjCreate("InternetExplorer.Application")
    myWB.Visible := True
    myWB.Navigate("http://blabla.domain.local/blah.aspx")
    IELoad(myWB)
    MsgBox, 64, Loaded, Loaded!
    If WinActive("ahk_class IEFrame") > 0
    {
        SetTitleMatchMode, 2
        WinGetActiveTitle, myTitle
            if InStr(myTitle, "Blah") > 0
            {
                ;MAIN CODE HERE
                myWB.document.getElementById("a_TransactionButton").Click()
                IELoad(myWB)
                Sleep, 500

                ;Now the links appear - We want id=a_statusChangeLink

                While (myVal <> "Change Status")
                    myVal:= myWB.document.getElementsByClassName("relatedLink")[A_Index].innerText, index := A_Index
                MsgBox, 64, Test, Count is: %myVal% and index is: %index%
                myWB.document.getElementsByClassName("relatedLink")[index].Click()

                ;This is an alternative way of getting that element

                links := myWB.document.getElementsByClassName("relatedLink")
                Loop, % links.length
                    n := A_Index - 1
                Until, links[n].innerText = "Change Status"
                links.item(n).click()

                ExitApp         
            }else
            {
                MsgBox, 64, Window not found, I did not detect an active Blah window...
                ExitApp
            }
    }
    MsgBox, 64, IE Not Found, I did not detect an active IE window...
    ExitApp
return

Esc::ExitApp

0 个答案:

没有答案
相关问题