我是 AHK 脚本的新手,我希望能够按 #n(Windows 键 + n)并在每次按下时触发一系列键盘组合(shift + end、alt + tab、^T、^V、enter、tab、enter)。
这是我所能得到的,但无论我在网上阅读多少内容,我都觉得我需要一些额外的帮助(那里的样本通常非常复杂)。
(感谢 Robert Ilbrink 编辑的最终代码对我有用,对他的提案进行了轻微的修改)
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2
#IfWinActive, Word ; #n will only trigger when working inside Word.
#n:: ; [Win]+n trigger key
ClipBoard = ; Clear ClipBoard
Send, +{End} ; [Shift]+[End]
Send, ^c ; Store selected text in ClipBoard
Sleep, 100 ; ClipWait seems unreliable
WinActivate, ahk_class Chrome_WidgetWin_1
Send, ^t ; In my Chrome setup I immediately get a Google search page.
Send, ^v;
Send, {Enter};
Sleep, 1000 ;
Send, {Tab}{Enter};
;SoundBeep, 500, 500
Return
#IfWinActive
答案1
Lolo,我会尝试一下,但是我仍然很困惑。
#SingleInstance Force
#installKeybdHook
#Persistent
SetTitleMatchMode, 2
#IfWinActive, Word ; #n will only trigger when working inside Word.
#n:: ; [Win]+n trigger key
ClipBoard = ; Clear ClipBoard
Send, +{End} ; [Shift]+[End]
Send, ^c ; Store selected text in ClipBoard
Sleep, 100 ; ClipWait seems unreliable
WinActivate, ahk_class Chrome_WidgetWin_1
Send, ^t ; In my Chrome setup I immediately get a Google search page.
WinWaitActive, Google - Google Chrome ; Wait for Google search Page
Send, %ClipBoard%{Enter} ; Send ClipBoard Text to Google
WinWaitActive, %ClipBoard% ; Wait for window title with search string
Send, {Tab}{Enter}
SoundBeep, 500, 500
Return
#IfWinActive
添加了 Tab+Enter 组合键。这在我的计算机上不起作用,因为 Tab 会跳转到黑色 Google+ 菜单栏……