I have no idea what is wrong with my idea and code. I tried changing some of the If GetKeyState()'s to check both the LShift and RShift states, but it's choppy. The second code kind of worked, but it had a really tough time counting to three and I had to spam the a key fast while also holding LShift and spam pressing the RShift key to get it to count to three....... So IDK...
Wait... I came up with this code:
a_array:=["à ","á","â","ä"]
;a_array:=["b","c","d","e"]
$+a::
If (A_PriorHotkey=A_ThisHotkey)
{
n++
If n=5
n:=1
Send {backspace}
Send % a_array[n]
}
else
{
n:=1
Send % a_array[n]
}
return
And when I didn't have the $, there were problems. The accented 'a' keys that AHK was producing were triggering the hotkey again, which was one of the problems... So, here's my original attempt with corrections. I think it's working better now.
a_array:=["à ","á","â","ä"]
$+a::
While GetKeyState("LShift","P") || GetKeyState("RShift","P")
{
number:=(!(x:=Mod(A_Index,4))?4:x)
Tooltip % number
If A_Index>1
Send {Backspace}
Send % a_array[number]
KeyWait, a
KeyWait, a, d t2
If ErrorLevel
Break
}
return
If you still want it to cycle through just by holding Shift in addition to being able to jump forward, remove the If ErrorLevel
and Break
lines.
My long-form code with the many many KeyWait and If GetKeyState()'s also had an error of using Send {Backspace} á
which should have been Send {Backspace}á
.
Edit: The previous code you shared looks like it needs to have several changes to get it to work for shift-only. I, or someone more competent than me, can try modifying that code if you'd prefer.