0

I am trying to implement Autoshift with AHK

Script waits for key release and when certain time elapses the Hotkey sends a shifted character.

The problem is that when I type keys very fast inputs are swapped:

I type ab - output is ba I type ba - output is ab

Is there any way to "flush" previous hotkey in waiting state or any way to achieve ordered Keys when using KeyWait?

script:

PushDuration := 250

$a::
    time := A_TickCount
    KeyWait, a
    var := A_TickCount - time
    if(var < PushDuration)
      SendEvent, a
    else 
      SendEvent, A
  return

$b::
    time := A_TickCount
    KeyWait, b
    var := A_TickCount - time
    if(var < PushDuration)
      SendEvent, b
    else 
      SendEvent, B
  return
0

You may (or may not) have better luck using separate 'up' hotkeys to handle the key-up events and get rid of the KeyWait calls.

You can also use A_ThisHotkey in conjunction with defining a single (generic) function for a bunch of keys and send a shifted version for whichever key triggered the function call. And/or, I believe the latest versions of AutoHotkey have a generic way to capture inputs without having to have a hotkey definition for each letter.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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