#group hotkeys

Propose new features and changes
SSpeed
Posts: 22
Joined: 04 Jul 2018, 09:48

#group hotkeys

21 Aug 2019, 16:10

regarding the Hotkey command:

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
		}
Currently have:

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.
iseahound
Posts: 460
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: #group hotkeys

21 Aug 2019, 23:18

There might be a better way to sort your hotkeys using the newest command InputHook.Onchar

https://www.autohotkey.com/docs/commands/InputHook.htm
lexikos
Posts: 6586
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: #group hotkeys

23 Aug 2019, 20:07

InputHook will only help if you want to reinvent the hotkeys themselves.

You could just use #If.

Code: Select all

broodwar_hotkeys_on()

; #group hotkeys, broodwar
	#if bw_on && winactive("ahk_class SWarClass")
		~numpadenter:: 
		~enter:: Suspend
		~esc:: Suspend OFF
		~s:: larvae()
		!F4:: broodwar_hotkeys_off()
	#if bw_on && winactive("ahk_class SWarClass") && ((pylon) || (mt_impossible))
		~b:: build_pylon()
	#if bw_on && winactive("ahk_class SWarClass") && (mt_impossible)
		~4::
		~5::
		~6::
		~7::
		~8::
		~9::
		~0:: use_spell()
#if ; #group


		broodwar_hotkeys_on() {
            global bw_on := true
		}
		broodwar_hotkeys_off() {
			global bw_on := false
		}
SSpeed
Posts: 22
Joined: 04 Jul 2018, 09:48

Re: #group hotkeys

23 Aug 2019, 21:14

Thanks, I like it.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 6 guests