【问题标题】:autohotkey inside autohotkey自动热键里面的自动热键
【发布时间】:2012-11-16 10:53:03
【问题描述】:

有没有办法在自动热键中编写自动热键?例如,我有一个自动热键,可以在我工作的选项卡中打开一些网站,我有一个自动热键,当我输入其中一些网站的用户名和密码时,我有一个自动热键。有没有办法将密码 autohotkey (actd(at symbol)) 放入 IE tabs autohotkey 中?我进行了一些搜索,但似乎无法发送 {@},所以我不确定是否有其他方法可以发送。

【问题讨论】:

  • 你试过将它们组合成一个脚本吗?请发布您的代码(同时修改任何用户名/密码)。

标签: autohotkey


【解决方案1】:

您的 AutoHotKey 脚本可以#Include 其他脚本,假设它们不是#Persistent。您可以遍历您的选项卡列表,然后调用一个或多个其他脚本。

就发送@ 符号而言,您应该可以毫无问题地使用Send 命令。如果您确实遇到了奇怪的问题,那么您可以尝试使用 SendRaw 命令或使用语法:Send {raw}@

如果这不能回答您的问题,请粘贴一些您正在尝试工作的代码。

【讨论】:

    【解决方案2】:

    您可以做的是编写两个单独的脚本。一个没有分配自动热键,但被初始脚本调用。在您的情况下,您已经说过您已经有一个 tabopening 热键,所以我将使用两个脚本的一个非常基本的示例,但演示如何发送 @ 符号并从热键中调用另一个脚本。

    我将使用的两个脚本是: tabOpener.ahk,和 passwordEntry.ahk

    它们会如下所示:

    tabOpener.ahk

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ; hotkey is set as WinowsKey+t and checks if FireFox exists, if so, it makes it active, if not, it starts FireFox
    ~#t::
    IfWinExist, ahk_class MozillaWindowClass
    {   WinActivate
        Send ^t
    } else run firefox
    
    ;Upon opening a new tab in FireFox, the address bar has already got focus, 
    ;so send the web address (You can use COM functions for this, and are highly 
    ;recommended, but out of the scope of this example)
    Send, hotmail.com{Enter}
    
    ;Waits until page is loaded.  Again COM functions are available as they can tell 
    ;when a page is finished loading, but that is a more involved example.
    Sleep 5000
    
    ;Calls the password entry script.
    Run passwordEntry.ahk
    return
    

    passwordEntry.ahk

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ;When using send, adding the {Raw} tag will literally interpret every 
    ;character in the remainder of a string.  For instance ^ will send ^ 
    ;instead of a Control keypress.
    Send {Raw}Username@domain.tld
    Send {Tab} {Raw}Password
    

    希望这会有所帮助。此示例展示了使用 {Raw} 标签发送特殊字符 (http://www.autohotkey.com/docs/commands/Send.htm),以及使用 Run / Runwait (http://www.autohotkey.com/docs/commands/Run.htm) 从现有热键中调用单独的脚本。

    【讨论】:

      【解决方案3】:
      ;~ Alt+1 to send username (email format) and password
      !1::Send, myUsername@mydomain.com{tab}myPassword{enter}
      

      【讨论】:

        【解决方案4】:

        根据您的 Web 浏览器,您可以使用 COM 对象轻松处理此问题。您会找到用户 ID 密码字段,然后例如:

        url := "http://yourwebsite.com"
        wb := ComObjCreate("InternetExplorer.Application") ; create broswer object
        wb.navigate(url)
        wb.visible := true ; sets the browser as visible, defaults as not
        While (wb.busy || wb.readyState <> 4)
            Sleep 100<br>
        wb.document.all.username.value := "yourname@wherever.com"
        wb.document.all.password.value := "Pa$$word15"
        wb.document.all.btnLogin.click()
        

        这取决于您是否使用 IE 访问您的网站。稍微看一下文档中的 COM 对象以了解它,您将在此处了解一些关于 DOM 的非常基本的东西:Basic DOM MSDN。我在 javascript 中设置“用户名”、“密码”和“btnLogin”控件 ID 的位置需要通过查看您的页面来发现。你也应该看看这个教程:AHK Basic COM/JavaScript Tutorial

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-03-20
          • 1970-01-01
          • 1970-01-01
          • 2011-03-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多