1
votes

Here is a short AHK script which does two things:

  1. Creates an extra Shift key on right alt (AltGr)
  2. Redefines CapsLock as a function key, to be used to type extra characters.
#InputLevel 1
RAlt::RShift      ; define shift on right-alt
SC03a::F20        ; define special function key on capslock
#InputLevel 0

F20 & SC002::  ; the '1' key
  GetKeyState, sh, Shift
  if sh = D
    Send ¡   ; upside-down exclamation
  else
    Send ¹   ; superscript 1
return

It nearly works:

  • pressing AltGr plus 1 produces '!', as you would expect for a shifted key.
  • pressing CapsLock plus 1 produces '¹', as you would expect given the definition above.

The problem arises when you hold down both AltGr and CapsLock and press '1'. This produces '¡' as expected for the first character, but subsequent presses produce '¹'. It appears the Shift state gets magically cancelled after the first press.

Note, this doesn't happen with a "real" Shift key - Caps+Shift+1 produces '¡' every time, so it appears to be a problem with redefining another key to be Shift, where its shift state is cancelled after the first instance.

Am I missing something?

1
Try using SendInput instead of Send. - Forivin
Fast reply! But unfortunately, with SendInput the result is exactly the same. - Steve
Okay, sorry I'm not sure what is causing it then. As a workaround you could simply do Send ¡{Shift Down}. It's not very elegant, but should work. - Forivin

1 Answers

0
votes

A while loop might be what you're looking for.

Example:

LShift::
while (GetKeyState("LShift", "P"))
{
    SendInput, {¡}
    Sleep, 100
}
return