I created this script from other forums. See if it's what you need:
(Be very careful when using this script. It is not a good idea to use Capslock as a keyboard shortcut.)
Code: Select all
OnExit, ExitSub
~^+CapsLock::
~CapsLock::
RepeatKey := !RepeatKey
If RepeatKey
SetTimer, SendTheKey, 100 ; The "100" here is the number of milliseconds between repeats.
Else
{
SetTimer, SendTheKey, Off
Send, {LShift Up}
Send, {LCtrl Up}
}
Return
SendTheKey:
Send, {LShift Down}
Send, {LCtrl Down}
Return
^+F10::
Msgbox, Keys are being pressed Ctrl+Shift
Return
^Esc::
^+Esc::
Send, {LShift Up}
Send, {LCtrl Up}
ExitApp
Return
ExitSub:
Send, {LShift Up}
Send, {LCtrl Up}
ExitApp
;-----Function---------
AutoRepeat(Key, Duration:=0)
{
End := A_TickCount + Duration
While, A_TickCount < End
{
SendInput, {%Key% DownR}
Sleep, 30
}
SendInput, {%Key% Up}
}
Attention! Always exit the program having disabled the keys to be pressed, otherwise it will interfere with other programs. To be safe better exit the script with the keyboard shortcut Ctrl+Esc. The commented out code should work, but it doesn't. Expert question: how to make sure that when exiting a script no key is left pressed?
One of the problems with this script proposal is that if you are pressing Ctrl+Shift, then the CapsLock keystroke is different (it will always be Ctrl+Shift+CapsLock, so you have to put two keyboard shortcuts). I have put the shortcut ^+F10 to verify that the condition is met, that you are holding down Ctrl+Shift, because pressing only F10 already has to meet the condition.
Another problem is that the caps lock light may blink. Hitting again deactivates it. At least on my system.