Want:
Code: Select all
#group hotkeys, broodwar
; skip to #group; the contents of this section are not important to the topic
#if winactive("ahk_class SWarClass")
~numpadenter::
~enter:: Suspend
~esc:: Suspend OFF
~s:: larvae()
!F4:: broodwar_hotkeys_off()
#if winactive("ahk_class SWarClass") && ((pylon) || (mt_impossible))
~b:: build_pylon()
#if winactive("ahk_class SWarClass") && (mt_impossible)
~4::
~5::
~6::
~7::
~8::
~9::
~0:: use_spell()
#group
broodwar_hotkeys_on() {
Hotkeys, a_group("broodwar"), on
}
broodwar_hotkeys_off() {
static runonce := broodwar_hotkeys_off()
Hotkeys, a_group("broodwar"), off
}
Code: Select all
; #group hotkeys, broodwar
; skip to #group; the contents of this section are not important to the topic
#if winactive("ahk_class SWarClass")
~numpadenter::
~enter:: Suspend
~esc:: Suspend OFF
~s:: larvae()
!F4:: broodwar_hotkeys_off()
#if winactive("ahk_class SWarClass") && ((pylon) || (mt_impossible))
~b:: build_pylon()
#if winactive("ahk_class SWarClass") && (mt_impossible)
~4::
~5::
~6::
~7::
~8::
~9::
~0:: use_spell()
; #group
broodwar_hotkeys_on(mode := "on") {
Hotkey if, winactive("ahk_class SWarClass")
Hotkey ~numpadenter, % mode
Hotkey ~enter, % mode
Hotkey ~esc, % mode
Hotkey ~s, % mode
Hotkey !F4, % mode
Hotkey if, winactive("ahk_class SWarClass") && ((pylon) || (mt_impossible))
Hotkey ~b, % mode
Hotkey if, winactive("ahk_class SWarClass") && (mt_impossible)
Hotkey ~4, % mode
Hotkey ~5, % mode
Hotkey ~6, % mode
Hotkey ~7, % mode
Hotkey ~8, % mode
Hotkey ~9, % mode
Hotkey ~0, % mode
}
broodwar_hotkeys_off() {
static runonce := broodwar_hotkeys_off()
broodwar_hotkeys_on("off")
}
the biggest issue, I believe, is not the number of lines that it takes up, but rather that users must remember to keep sections of code synchronized.