How to use hotkey,off in #IfWinActive section

2019-06-13 17:06发布

问题:

I am using the following code:

#IfWinActive ahk_class Notepad
4::Send,4
5::
    Hotkey,4,off
;~  do something
    Hotkey,4,on
    Return
#IfWinActive

but it generates this error:

Prompt Error:  Nonexistent hotkey variant (IfWin).

回答1:

I don't understand what you mean by using 4 to send 4 - it seems redundant.

I tried it like this. pushing 4 will send 6, and pushing 5 will send 4.

#IfWinActive ahk_class Notepad
{
    4::Send,6
    5::
        Hotkey,4,off
        send, 4
        Hotkey,4,on
    Return
}

The idea here is that the brackets encase the entire function within the IfWinActive. If notepad isn't active, nothing at all happens.



标签: autohotkey