我希望能夠從 Autohotkey 觸發“搜索標簽”,因為我有很多打開的標簽,這將幫助我快速找到我正在尋找的標簽,我知道我可以通過撰寫腳本來遍歷所有標簽,但這不是我想要的。
這就是我所做的
! a::
WinActivate, Brave
Sleep, 100
Send, {Ctrl}{Shift}a
Return
如果我改變Send, {Ctrl}{Shift}a與Send, {Ctrl}t被正確打開一個標簽,所以這個問題必須是在我的一些錯誤{Ctrl}{Shift}a配置或勇敢不知何故沒有反應。
uj5u.com熱心網友回復:
激活特定視窗并向其發送按鍵的最合適方法如下:
! a::
SetTitleMatchMode, 2 ; if you want to use it only in this hotkey
IfWinNotExist, Brave
{
MsgBox, Cannot find Brave
Return ; end of the hotkey's code
}
; otherwise:
WinActivate, Brave
WinWaitActive, Brave, ,2 ; wait 2 seconds maximally until the specified window is active
If (ErrorLevel) ; if the command timed out
{
MsgBox, Cannot activate Brave
Return
}
; otherwise:
; Sleep 300 ; needed in some programs that may not react immediately after activated
Send, ^ a
Return
否則腳本可以將擊鍵發送到另一個視窗。
為了不在每個熱鍵中重復整個代碼,您可以創建一個函式:
! b::
SetTitleMatchMode, 2
Activate("Brave", 2)
; Sleep 300
Send, ^ a
Return
Activate(title, seconds_to_wait){
IfWinNotExist, % title
{
MsgBox % "Cannot find """ . title . """."
Return
}
; otherwise:
WinActivate, % title
WinWaitActive, % title, ,% seconds_to_wait
If (ErrorLevel)
{
MsgBox % "Cannot activate """ . title . """."
Return
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/312660.html
