Divide script into different hotkey groups

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
peds
Posts: 4
Joined: 21 Jun 2021, 03:37

Divide script into different hotkey groups

21 Jun 2021, 04:27

Hi,

I would like to divide my single-file ATH script into different parts, and activate that parts with "different" hotkeys. This is is just in order to have different sets of many shortcuts active for different instant occasions - better keyboard layout customization. If I split it in different ATH files, and suspend or exit these files, I experience 1 sec delay toggling them back between active/suspend and I type way faster.

I look for sth simple like that:

Code: Select all

capslock::   - master hotkey to activate one set of hotkeys
{
q::1  
w::2
e::3
}
2nd time capslock::  - another master hotkey to activate other set of hotkeys
{
r::4
t::5
y::6
}
[Mod edit: [code][/code] tags added.]

3rd time capslock the beginning state.

Cheers
Piotr
Last edited by peds on 21 Jun 2021, 11:39, edited 3 times in total.
User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Divide script into different hotkey groups

21 Jun 2021, 06:59

Here is one way.

Code: Select all

CapsLock::set := !set
#If set
q::1
#If
peds
Posts: 4
Joined: 21 Jun 2021, 03:37

Re: Divide script into different hotkey groups

21 Jun 2021, 07:34

Thanks Mike,

And how about just using capslock to toggle between different sets of hotkeys, instead just toggling one set. E.g. second capslock press turns on second set and third press returns to beginning state?
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Divide script into different hotkey groups

21 Jun 2021, 09:51

Hallo,
how about this?
The different sets of hotkeys are set by the key combination Capslock & some other key:

Code: Select all

capslock::Return
#IF GetKeyState("capslock","P")
*a:: ;capslock & a
*b:: ;capslock & b
*c:: ;capslock & c
; ...
MasterHotkey := A_ThisHotkey
Return
#IF MasterHotkey = "*a"
q::1
w::2
e::3
#IF MasterHotkey = "*b"
r::4
t::5
y::6
#IF MasterHotkey = "*c"
z::7
;...
peds
Posts: 4
Joined: 21 Jun 2021, 03:37

Re: Divide script into different hotkey groups

21 Jun 2021, 10:38

Thank you for hints,

For the easy and fast typing I will try to find how to switch just two different sets, and also using just one key for that - avoiding key combinations at all. This proposed shift+capslock combination in my question was not the best solution as well (I corrected it to 2*capslock), it was just roughly explaining what I mean - just pointing at the usage of a no so useful capslock.
WalterRoberts
Posts: 67
Joined: 25 Feb 2020, 20:00

Re: Divide script into different hotkey groups

21 Jun 2021, 14:33

Code: Select all

SetCapsLockState, AlwaysOff

CapsLock::
	iteration++
	MsgBox, % "Iteration No. " iteration	; Only for Logging
	
	if (iteration = 1)
	{
		set4 := false
		set1 := true
	}
	if (iteration = 2)
	{
		set1 := false
		set2 := true
	}
	if (iteration = 3)
	{
		set2 := false
		set3 := true
	}
	if (iteration = 4)
	{
		set3 := false
		set4 := true
		iteration := 0
	}
return


#If set1
	F1::1

#If set2
	F1::2

#If set3
	F1::3

#If set4
	F1::4
	
#If

peds
Posts: 4
Joined: 21 Jun 2021, 03:37

Re: Divide script into different hotkey groups

21 Jun 2021, 14:51

Thank you Walter, that should sort it. CHEEERSSSSSS :wave:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Holarctic, jameswrightesq, wpulford and 409 guests