I wanted to play with autoshift functionality. That is, if any of the alphanumeric keys is pressed longer than some timer, "shift" is automatically applied.

I would imagine that someone has already implemented this or very similar functionality on autohotkey. However, I am complete newbie with autohotkey and I am having troubles for finding relevant examples. Could someone point me to them or give me some tips about how to get started?

; create an array/object of the keys you want shift:
Keys := ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0"]

; create a hotkey once for each key in this object, using a For-Loop:
For each, key in Keys
    Hotkey, $%key%, Shift_Key ; the $ prefix forces the keyboard hook to be used

    ThisHotkey := StrReplace(A_ThisHotkey, "$") ; remove the $ prefix 
    KeyWait, %ThisHotkey%, T0.3 ; wait max. 0.3 seconds for the key to be released
    If (ErrorLevel) ; if the command timed out (long press, the key is still pressed after 0.3 seconds)
        SendInput, +%ThisHotkey% ; "shift" it
        SendInput, %ThisHotkey%
    KeyWait, %ThisHotkey% ; don't repeat the action before the key is released





Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.