Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My script already has many #IfWinActive lines, and I am currently using #IfWinNotActive on many of my global hotkeys to disable them when I have a certain window active. However, this is not a very clean solution and now I have more than one program I would like to disable my hotkeys for. Currently, I manually suspend and unsuspend my script, but this gets pretty tedious.

I was wondering if there's a way to automatically suspend the script when a certain program is active and unsuspend when the program loses focus.

share|improve this question
add comment

1 Answer

If the script is suspended, then how would it un-suspend itself? Your best bet is to put the main script in a thread and have another thread responsible for suspending and resuming the first thread.

share|improve this answer
    
Ah yes, you are right about that. Maybe the question should be about how to disable hotkeys rather than suspend/unsuspend. Your solution requires the other thread to constantly run to check the current active window, right? or something of the sort? –  Kevin Lau Jul 25 '12 at 4:21
    
Not necessarily. You could design your script so that the control thread simply toggles the hotkeys in the main thread using the Hotkey command. –  Synetech Jul 25 '12 at 4:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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