Page 1 of 1
Pause all hotkeys
Posted: 02 Oct 2019, 03:57
by roysubs
I have an autohotkey script "Main.ahk" that has a few thousand lines with all of my hotkeys.
However, I recently started using an old game emulator (ZX Spectrum lol) and when I am in that, my automation messes up the games, so I have to exit Main.ahk before I run that.
Alternatively, is there a way to put a global directive into Main.ahk that says "if application spectrum.exe is running, then ignore all hotkeys in this script" ?
Re: Pause all hotkeys Topic is solved
Posted: 02 Oct 2019, 04:41
by Sid4G
use suspend hotkey, eg. if scroll lock light is on then use default, else use your hotkeys.
Re: Pause all hotkeys
Posted: 02 Oct 2019, 04:43
by gregster
You can create
context-sensitive hotkeys by putting a directive above the relevant or all hotkeys:
#IfWin[Not]Active or
#IfWin[Not]Exist:
Docs
or
#If:
Docs
Options:
Code: Select all
#IfWinNotActive ahk_exe spectrum.exe
space::msgbox Works only if spectrum.exe window is not active
Numpad1::msgbox Another hotkey
; more hotkeys here
#If ; end of 'context-sensitive hotkeys' section - optional
Code: Select all
#IfWinNotExist ahk_exe spectrum.exe
space::msgbox Works only if spectrum.exe window does not exist
; more hotkeys here
#If ; end of 'context-sensitive hotkeys' section - optional
Code: Select all
#If !WinExist("ahk_exe spectrum.exe") ; '!' is logical 'NOT'
space::msgbox Works only if spectrum.exe window does not exist
; more hotkeys here
#If ; end of 'context-sensitive hotkeys' section - optional
Re: Pause all hotkeys
Posted: 02 Oct 2019, 07:43
by roysubs
Great, thanks. For my needs, the Suspend is perfect, I'll just use a toggle
^#!s::Suspend, Toggle
I guess the 'Toggle' is redundant as that's the default behaviour.
Thanks also for the overview of all of the IfWin[Not]Active / #IfWin[Not]Exist / #If [!]WinExist options.