why does the following AHK-Script produce the warning mentioned in the subject when pressing "x"?
#IfWinActive AnyName x:: #IfWinActive $x:: Send x
I use AutoHotkey v1.0.48.05.L61 and Windows 7 64bit.
#IfWinActive AnyName x:: #IfWinActive $x:: Send x
$x:: Send xThen it should work.
#IfWinActive ahk_class Notepad $x:: #IfWinActive x:: Send x
#IfWinActive ahk_class Notepad
^!c::MsgBox You pressed Control+Alt+C in Notepad.
#IfWinActive ahk_class WordPadClass
^!c::MsgBox You pressed Control+Alt+C in WordPad.
#IfWinActive
^!c::MsgBox You pressed Control+Alt+C in a window other than Notepad/WordPad.
should not send the hotkey to itself, since I used the modifier symbol "$". However it does send the hotkey to itself if there are also the lines$x:: Send x
#IfWinActive AnyName x:: #IfWinActivewhich actually shouldn't have any effect at all unless there's a certain window active.
x:: Send xis a self-triggering Hotkey. However, for any strange reasons, the warning message does not occur if there are the additional lines
#IfWinActive ahk_class Notepad $x:: #IfWinActive
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
By itself - yes. However, I put a Hook on the first instance of the x-hotkey. If you want to argue that that hook shouldn't matter because it's in an #If-directive, you might have a good point. Also note, you could switch the order of the hotkey definitions, as long as the first hotkey definition has the hook:x:: Send xis a self-triggering Hotkey.
$x:: Send x #IfWinActive ahk_class Notepad x:: #IfWinActive
#IfWinActive AnyName x:: Return #IfWinActive $x:: Send x Return
Type Off? Running Name ------------------------------------------------------------------- reg xThere are two reasons for this:
The second hotkey is a single line hotkey. The first hotkey is not, since there is no command to the right of "::". It is similar to the following, which specifies multiple criteria for a single hotkey:Returns are not necessary, since the hotkey definitions comprise each only a single line.
#IfWinActive AnyName x:: #IfWinActive OtherName x:: #IfWinActive ; Reset for any other hotkeys below. Send x return y::MsgBox This hotkey is not context-sensitive.
Now if any instance of the hotkey has $ or #UseHook, it applies to all instances of that hotkey.Fixed: $ and #UseHook had no effect if used only on the second or subsequent instance(s) of a hotkey.