Code: Select all
#IfWinActive ahk_class Notepad++
KeyWait, d, D
msgbox d is down
#IfWinActive
Code: Select all
#IfWinActive ahk_class Notepad++
~d::
KeyWait, d, D
msgbox d is down
return
#IfWinActive

Code: Select all
#IfWinActive ahk_class Notepad++
KeyWait, d, D
msgbox d is down
#IfWinActive
Code: Select all
#IfWinActive ahk_class Notepad++
~d::
KeyWait, d, D
msgbox d is down
return
#IfWinActive
#if... things only work on hotkeys or hotstrings, not commands.tutorial wrote:Sometime you might want a hotkey or hotstring to only work (or be disabled) in a certain window.
but if you use an if on your first code, chances are it'll close immediately since the IF fails and skips the keywait and it'll have nothing else to do, so it'll close.G33kDude wrote:while 'If' handles what commands get run under what conditions, '#If' handles what hotkeys are enabled under what conditions
Users browsing this forum: Aggronaught, Google [Bot], keylo, mikeyww, Netocon, nxnure, scriptor2016, tatermakes and 35 guests