I am writing a script to make the AltGr (Right Alt) key apply some custom diacritics to certain letters.
For each of these letters, I have two rules.
<^>!g::
{
if GetKeyState("CapsLock", "T")
SendInput "Ġ"
else
SendInput "ġ"
}
+<^>!g::
{
if GetKeyState("CapsLock", "T")
SendInput "ġ"
else
SendInput "Ġ"
}
This should handle all cases (no pun intended) where the caps lock is toggled on/off and/or the shift key is held.
However I have come across a bug where whenever GetKeyState("CapsLock", "T")
returns 1
, caps lock is toggled off then on in quick succession before the custom letter is actually printed to the screen, causing the indicator light on my caps lock key to flicker and the ‘Caps Lock On’ prompt to appear on the screen.
Example 1:
Caps Lock has been enabled and I have waited for the prompt to disappear from the screen. I then press AltGr + G expecting Ġ to be printed to the screen. It is printed to the screen but the toggle status indicator light flickers on my caps lock key and this prompt appears on the screen.
Example 2:
Similar to Example 1, but I hold shift, expecting ġ to be displayed on the screen, which it does, but with the same side effects as Example 1.
1