*::
is not a "catch all" hotkey, it just fires when it detects an asterisk (normally Shift+8).
To achieve your desired effect, you should activate the hotkeys based on the active window.
Working Example
If the active window is an InputBox
(ahk_class #32270
), disable the hotkeys, but don't block their native function (the ~
prefix). If not the InputBox
, bind the hotkeys as desired.
#SingleInstance force
currentstring := ""
return ; end auto-execute section
#IfWinActive, ahk_class #32770 ; If an InputBox window, restore default key function
~q::
~w::
~e::
~r::
~t::
return
#IfWinActive ; If anything else
q::
ExitApp
return
w::
MsgBox,,,Hello`, World!,3
return
e::
MsgBox,,,Hello World,3
return
r::
InputBox, currentstring
return
t::
MsgBox,,,%currentstring%,3
return
Notes:
- It is considered best practice to only bind the hotkeys you need, not to everything.
- To determine a Window's properties (class, id, etc.), you can use the Active Window Info or Window Spy tool bundled with AutoHotKey. It can also be launched from the system tray icon of a running script if
Menu, Tray, NoStandard
has not been used.