3

An excerpt from AHK doc:

How can a hotkey or hotstring be made exclusive to certain program(s)? In other words, I want a certain key to act as it normally does except when a specific window is active.

The preferred method is #IfWinActive. For example:

#IfWinActive, ahk_class Notepad
^a::MsgBox You pressed Control-A while Notepad is active.

This works fine, but the entire rest of the AHK script file is conditionally run only when Notepad is focused.

How do I end the #IfWinActive. Better yet, where is the documentation that explains what # followed by a thing means.

3

I found more documentation that fully explains what's going on here.

This language does not use an endif. You just write #if with no args to specify the negative case.

Terrible language. ;) But, it actually makes sense. This is less expressive from a programming point of view, but since the script is a configuration, 99% of the time you do want to split the binds into equally mutually exclusive zones of the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.