I want to create some hotkeys when no window is active:
But there's no statement like #IfNoWinActive
, how to achieve this?
CodePudding user response:
There is always an active window (the one that will get input).
E.g. the Win X Menu has no title but a hidden ahk_class (LauncherTipWnd). To detect it you have to add DetectHiddenWindows, On
in your script:
#NoEnv
#SingleInstance Force
DetectHiddenWindows, On
#IfWinActive ahk_class LauncherTipWnd ; Win X Menu
F1:: Run notepad
F2:: Send m ; starts the Device Manager
#IfWinActive
EDIT:
To get the title and ahk_class of the (hidden) active window, run this script and press F1 as soon as that window is active:
#NoEnv
#SingleInstance Force
DetectHiddenWindows, On
F1::
WinGetTitle, ActiveTitle, A
WinGetClass, ActiveClass, A
MsgBox, ActiveTitle: