【问题标题】:how to click button using Autohot key如何使用 Autohotkey 单击按钮
【发布时间】:2023-02-17 06:17:04
【问题描述】:

您好,我只是想寻求一些关于重新使用 autohotkey 的帮助,我正在执行脚本自动化并使用 autohotkey 浏览该网站。我对 autohotkey 了解不多,但有没有办法使用 autohot 键单击“按包裹编号搜索”按钮?因为我注意到单击链接时 Class 随 Active 发生变化。如果可以在自动热键中执行,我只想单击“按包裹编号搜索”按钮。

我的脚本是这样的

        SendRaw Search by Parcel Number
        Sleep KeySleepSlow
        Send {esc}
        Sleep KeySleepSlow
        Send {enter}

**这是网址https://www.indy.gov/workflow/property-taxes

谢谢你希望有人教育我。**

【问题讨论】:

    标签: autohotkey


    【解决方案1】:

    AHK 可以通过多种方式与网页进行交互。一种快速而肮脏的方法是简单地让 AHK 告诉浏览器去做。

    可以在地址栏中使用 Javascript 与页面进行交互,但它有一些技巧。下面脚本中的 cmets 应该可以解释这一切:

    +space:: ; Triggered with Shift+Space
        GoSub mySub1
    Return
     
    mySub1:
        ;The original clipboard contents is first saved in a variable so that it is not lost when the script is run.
        originialClipboard := Clipboard
        
        ;The clipboard is used so that the text is quickly entered into the address bar, instead of having each character typed out.
        ;Javascript is used to simulate a click on the desired document element. The 'j' is omitted by design.
        Clipboard := "avascript:document.evaluate(""//a[text()='Search by parcel number']"", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.click();"
    
        ;CTRL+L puts the text cursor in the address bar. Then the letter "j" is typed, because Chrome does not allow the text "javascript:" to be pasted in. The rest of that string will be pasted in later.
        send ^lj ;  
    
        ;CTRL+V pastes the clipbard 
        send ^v
        sleep 1 ;Sleep for a short moment to allow the browser to catch up.
        send {enter} ;The Enter key is sent, executing the javascript, simulating a click on the button.
        
        ;The clipboard is restored to its original value
        clipboard := originialClipboard
        
    Return
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多