I have a keyboard with these arrow (less/greater than) characters as alternate keys on Y and X.
Let's focus on the key X for this example.
By default the alternate character > is triggered with AltGr + X of course.
But I would like to trigger it by simply long pressing X, to speed things up and having no need for a second hand or finger.
So far I have the following, which I got from other posts:
$x::
KeyWait, x, T0.2
if (ErrorLevel)
Send > ;long
else {
KeyWait, x, D T0.2
if (ErrorLevel)
Send x ;single
}
KeyWait, x
return
This basically works, but has one major flaw: A normal single key press takes now too much time to write the normal X character.
For instance, if you write fast a word like "exchange", you end up with something like "echxange", because the X takes too much time to be sent.
So how can this script be modified to fix that problem? My idea would be to send a normal X and to abord this whole script, once a {X Up} is registered. So after {X Up} he will no longer wait.
Or any other idea?
Thanks.
Here is a solution that calculates the duration of the keypress, the downside is you always have to release the key in order to get the required input. This means you can't hold down x to type xxxxxxxx.
$x::
startTime := A_TickCount ;record the time the key was pressed
KeyWait, x, U ;wait for the key to be released
keypressDuration := A_TickCount-startTime ;calculate the duration the key was pressed down
if (keypressDuration > 200) ;if the key was pressed down for more than 200ms send >
{
Send >
}
else ;if the key was pressed down for less than 200ms send x
{
Send x
}
return