[英]How can I pass the intercepted key through to an application in autohotkey
I'm constantly activating Firefox then hitting Ctrl + L to focus the location bar and do a search or type a URL. 我一直在激活Firefox,然后按Ctrl + L聚焦位置栏并进行搜索或输入URL。
Ideally I can be in any application and hit Ctrl + L and Firefox will be activated with the location bar focused and ready for input. 理想情况下,我可以在任何应用程序中按Ctrl + L ,Firefox将在位置栏聚焦并准备好输入的情况下激活。 In steps AutoHotkey scripting. 在步骤AutoHotkey脚本。
I've tried this and it doesn't seem to work. 我试过这个,似乎没有用。 From what I've read, tilde is "pass-through": 从我所读到的,代字号是“传递”:
^l::
IfWinExist ahk_class MozillaUIWindowClass
{
WinActivate
Send ~^l
}
Ended up getting the answer to this one myself on the AHK forum . 结束了我在AHK论坛上得到这个答案。
It requires the use of the dollar sign modifier ($). 它需要使用美元符号修饰符($)。
$^l::
IfWinExist ahk_class MozillaUIWindowClass
{
WinActivate
Send ^l
}
From AutoHotkey help: 从AutoHotkey帮助:
($) This is usually only necessary if the script uses the Send command to send the keys that comprise the hotkey itself, which might otherwise cause it to trigger itself. ($)这通常只有在脚本使用Send命令发送组成热键本身的键时才需要,否则可能会导致它自己触发。
And here's the full script I ended up using. 这是我最终使用的完整脚本。 If Firefox is already active Ctrl+L is simply passed through and behaves as usual. 如果Firefox已经处于活动状态,则只需传递Ctrl + L并像往常一样运行。 If outside of Firefox when Ctrl+L is pressed then Firefox is activated and a new tab is created; 如果在Firefox外部按下Ctrl + L,则激活Firefox并创建一个新选项卡; ready for searching. 准备好搜索。
$^l::
IfWinExist ahk_class MozillaUIWindowClass
{
IfWinActive ahk_class MozillaUIWindowClass
{
Send ^l
}
else
{
WinActivate
Send ^t
}
}
I don't think the tilde applies in this instance, but Send might send the keys faster than the window actually activates, so something like this might be better: 我不认为代字号适用于此实例,但Send可能比窗口实际激活时更快地发送密钥,所以这样的事情可能会更好:
SetKeyDelay, 10, 10 ; adds 10ms delay between and during keystrokes
IfWinExist, ahk_class MozillaUIWindowClass
{
WinActivate,
WinWaitActive, ; waits until window is active
Send, ^l
}
return
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.