I have a bluetooth remote with a Browser_Home key, which I'm attempting to remap with AutoHotkey on my Windows 10 machine.
By default, pressing Browser_Home does one of two things:
- If the window in focus is my default browser (Firefox in my case), the current tab switches to the new tab page.*
- If the window in focus is anything else, a new browser window is opened and brought into focus, opened to the new tab page.*
* Presumably, my configured homepage would open had I configured it to anything else.
Now I attempt to remap the Browser_Home using AutoHotkey:
Browser_Home::
MsgBox Browser home button pressed
Return
(Edit: This is the entirety of the script I'm running, and I made sure it's the only AHK script running.)
The effects are different, depending on whether I have a Firefox window in focus when I press Browser_Home :
- If the window in focus is my default browser (Firefox in my case), the desired behavior occurs: The key press is intercepted and a message box pops up. No browser tabs are affected.
- If the window in focus is anything other than a default browser window, the AHK script appears to have no effect: A new browser window is opened and brought into focus, opened to the new tab page. No message box pops up.
Note that the same behavior appears to occur if I switch MessageBox
with TrayTip
or Send
.
Clearly the remap fails when a default browser window is not in focus! This is a huge percentage of my usage cases, and as such extremely undesirable. Is there any way to successfully remap the Browser_Home key all the time?
Note: I know for sure the key in question is Browser_Home from AutoHotKey's keypress history.
#IfWinActive
clause.#IfWinActive
in windows' processing of aBrowser_Home
keypress -- c.f. my description of the default keypress behavior, and how it depends on the window in focus.