[英]autohotkey inside autohotkey
有沒有辦法在自動熱鍵中編寫自動熱鍵? 例如,我有一個自動熱鍵,可以為我在工作中的標簽頁中打開一些網站,我有一個自動熱鍵,鍵入時會為其中一些網站輸入用戶名和密碼。 有沒有辦法將密碼自動熱鍵(actd(在符號處))放在IE選項卡自動熱鍵內? 我做了一些搜索,看起來好像無法發送{@},所以我不確定是否還有其他方法可以發送。
您可以做的是編寫兩個單獨的腳本。 一個沒有分配自動快捷鍵,但是被初始腳本調用。 在您的情況下,您已經說過已經有一個制表符打開的熱鍵,因此我將使用兩個腳本的非常簡單的示例,但演示如何發送@符號並從熱鍵中調用另一個腳本。
我將使用的兩個腳本是: tabOpener.ahk
和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.
; 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
#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 /從現有的熱鍵中調用單獨的腳本運行等待( http://www.autohotkey.com/docs/commands/Run.htm )。
;~ Alt+1 to send username (email format) and password
!1::Send, myUsername@mydomain.com{tab}myPassword{enter}
根據您的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教程
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.