Pause all hotkeys Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Pause all hotkeys

02 Oct 2019, 03:57

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" ?
Sid4G
Posts: 48
Joined: 02 Apr 2016, 19:11

Re: Pause all hotkeys  Topic is solved

02 Oct 2019, 04:41

use suspend hotkey, eg. if scroll lock light is on then use default, else use your hotkeys.
gregster
Posts: 9060
Joined: 30 Sep 2013, 06:48

Re: Pause all hotkeys

02 Oct 2019, 04:43

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
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Re: Pause all hotkeys

02 Oct 2019, 07:43

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 191 guests