#HotkeyModifierTimeout

Affects the behavior of hotkey modifiers: CTRL, ALT, WIN, and SHIFT.

#HotkeyModifierTimeout Milliseconds

 

Parameters

Milliseconds The length of the interval in milliseconds. The value can be -1 so that it never times out (modifier keys are always pushed back down after the Send), or 0 so that it always times out (modifier keys are never pushed back down).

 

Remarks

This directive need not be used if the script has the keyboard hook installed (you can see if your script uses the hook via the "View->Key history" menu item in the main window, or via the KeyHistory command). This is because the hook can keep track of which modifier keys (ALT/CTRL/WIN/SHIFT) the user is physically holding down and doesn't need to use the timeout.

To illustrate the effect of this directive, consider this example:
^!a::Send, abcdefg

When the Send command executes, the first thing it does is release the CTRL and ALT keys so that the characters get sent properly. After sending all the keys, the command doesn't know whether it can safely push back down CTRL and ALT (to match whether the user is still holding them down). But if less than the specified number of milliseconds have elapsed, it will assume that the user hasn't had a chance to release the keys yet and it will thus push them back down to match their physical state. Otherwise, the modifier keys will not be pushed back down and the user will have to release and press them again to get them to modify the same or another key.

The timeout should be set to a value less than the amount of time that the user typically holds down a hotkey's modifiers before releasing them. Otherwise, the modifiers may be restored to the down position (get stuck down) even when the user isn't physically holding them down.

You can ensure that the keyboard hook is installed, thus making the use of this directive unnecessary, by adding the line #InstallKeybdHook anywhere in the script (the hook is not currently supported on Win9x). Alternatively, reducing SetKeyDelay to 0 or -1 should help because it makes SEND run more quickly.

If this is directive is unspecified in a script, it behaves as though set to 50.

 

Related

GetKeyState

 

Example

#HotkeyModifierTimeout 200