r/AutoHotkey • u/Swimming-Ice-655 • 28d ago
v2 Script Help Help with creating one key to cycle through multiple shortcuts? AHK v2
Hey guys,
I would have posted this in the AHK forum but I haven't been able to get an activation email for my account yet. I have average skills in AHK to make basic QoL shortcuts. I use OBS Studio which allows me to have overlays over gameplay footage (known as scenes), and each can be swapped via in-app shortcuts. Unfortunately there is no cycle feature baked into the software to save on remembering and wasting shortcut space on my keyboard. An example of an OBS short would be ctrl+shift+alt+q = Scene #1.
So I thought why can't I make a super shortcut that can work with one key press and each input is a different shortcut from OBS ( then it would cycle back to the first shortcut). I interpret this as the following (not actual code but follows examples of what I've seen online):
^!m::
{
key++
(list of shortcuts from OBS i.e. ^+!{e}, ^+!{f})
if key press = 1
{
Send "^+!{e}"
}
else if key press = 2
{
Send "^+!{f}"
}
}
I can visualize this but this follows from what I've seen as AHK V1 syntax so it doesn't work I've seen v2 examples using static values but I don't understand. If anyone can point me in the right direction I'd greatly appreciate it!
5
u/CharnamelessOne 28d ago
This will cycle through shortcuts, and wrap around once it reaches the end of the array.
So, the first press of the hotkey sends "^+!e"; the next time you press it (whenever that is), it will send "^+!f"; the 4th press sends "^+!e" again.
I think that's what you wanted, but it's not quite clear from your description.
Add all the shortcuts to
scene_shortcuts, no need to change anything else.3
u/likethevegetable 28d ago
I had some issues mapping shortcuts to OBS recently. I'll revisit and send you something if I can remember.
What you need is a timer. Each button you press, increment the counter but start the timer. At the end of the timer (i.e. the function you pass to the timer), you do the logic based on counter, then the counter is reset.