Cycle 1,2,4 with one button.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
poly2poly
Posts: 2
Joined: 15 Sep 2021, 03:02

Cycle 1,2,4 with one button.

15 Sep 2021, 03:20

Hello, I'm new to this forum. :D
I was looking for a way to cycle thru keys using spacebar. After some google search I found this code and it works. Modified it to work with spacebar.
One thing I can't figure out is how to skip 3 and immediately go to 4 key because in 3dsmax I don't use the 3 key. I tried editing the code and testing but can't figure it out. Any help appreciated.

Original

Code: Select all

$1::	; $ blocks the hotkey form triggering itself
 key++
 if key = 1
    Send, 1

 else if key = 2
    Send, 2

 else if key = 3
    Send, 3

 else if key = 4
 {
    Send, 4
    key = 0                   
 }
return

Modified

Code: Select all

#IfWinActive, ahk_class 3DSMAX

Space::1


$Space::	; $ blocks the hotkey form triggering itself
 key++
 if key = 1
    Send, 1

 else if key = 2
    Send, 2

 else if key = 3
    Send, 3

 else if key = 4
 {
    Send, 4
    key = 0                   
 }
return
User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Cycle 1,2,4 with one button.

15 Sep 2021, 06:22

Code: Select all

n := 0
#IfWinActive ahk_class 3DSMAX
Space::Send % SubStr(124, Mod(n++, 3) + 1, 1)
#IfWinActive
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Cycle 1,2,4 with one button.

15 Sep 2021, 08:23

Hallo,
or:

Code: Select all

n := 2
#IfWinActive ahk_class 3DSMAX
Space::Send,% 2**n:=Mod(n+1,3)
#IfWinActive
poly2poly
Posts: 2
Joined: 15 Sep 2021, 03:02

Re: Cycle 1,2,4 with one button.

16 Sep 2021, 00:44

Thanks Guys! I tried the last one and it works flawlessly. Have to study what the code means it's very interesting.
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Cycle 1,2,4 with one button.

16 Sep 2021, 01:58

another version:

Code: Select all

n := 0
#IfWinActive ahk_class 3DSMAX
Space::Send,% 1<<Mod(n++,3)
#IfWinActive

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 241 guests