Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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. In steps AutoHotkey scripting.

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
}
like image 976
GollyJer Avatar asked Feb 28 '10 01:02

GollyJer


1 Answers

Ended up getting the answer to this one myself on the AHK forum.
It requires the use of the dollar sign modifier ($).

$^l::
IfWinExist ahk_class MozillaUIWindowClass
{
    WinActivate
    Send ^l
}  


From AutoHotkey help:

($) 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.


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. If outside of Firefox when Ctrl+L is pressed then Firefox is activated and a new tab is created; ready for searching.

$^l::
IfWinExist ahk_class MozillaUIWindowClass
{
  IfWinActive ahk_class MozillaUIWindowClass
  {
    Send ^l
  }
  else
  {
    WinActivate
    Send ^t
  }
}
like image 94
GollyJer Avatar answered Oct 21 '22 19:10

GollyJer