Each numpad key can be made to launch two different hotkey subroutines depending on the state of Numlock. Alternatively, a numpad key can be made to launch the same subroutine regardless of the Numlock state. For example:
NumpadEnd::
Numpad1::
MsgBox, This hotkey is launched regardless of whether Numlock is on.
return
If the tilde (~) operator is used with a prefix key even once, that prefix will always be sent through to the active window. For example, in both of the below hotkeys, the active window will receive all right-clicks even though only one of the definitions contains a tilde:
~RButton & LButton::MsgBox You pressed the left mouse button while holding down the right.
RButton & WheelUp::MsgBox You turned the mouse wheel up while holding down the right button.
The Suspend command can temporarily disable all hotkeys except for ones you make exempt. For greater selectivity, use #IfWinActive/Exist.
By means of the Hotkey command, hotkeys can be created dynamically while the script is running. The Hotkey command can also modify, disable, or enable the script's existing hotkeys individually.
Joystick hotkeys do not currently support modifier prefixes such as ^ (Control) and # (Win). However, you can use GetKeyState to mimic this effect as shown in the following example:
Joy2::
if not GetKeyState("Control") ; Neither the left nor right Control key is down.
return ; i.e. Do nothing.
MsgBox You pressed the first joystick's second button while holding down the Control key.
return
There may be times when a hotkey should wait for its own modifier keys to be released before continuing. Consider the following example:
^!s::Send {Delete}
Pressing Control-Alt-S would cause the system to behave as though you pressed Control-Alt-Delete (due to the system's aggressive detection of Ctrl-Alt-Delete). To work around this, use KeyWait to wait for the keys to be released; for example:
^!s::
KeyWait Control
KeyWait Alt
Send {Delete}
return
A hotkey label can be used as the target of a Gosub or Goto. For example: Gosub ^!s
One common use for hotkeys is to start and stop a repeating action, such as a series of keystrokes or mouse clicks. For an example of this, see this FAQ topic.
Finally, each script is quasi multi-threaded, which allows a new hotkey to be launched even when a previous hotkey subroutine is still running. For example, new hotkeys can be launched even while a MsgBox is being displayed by the current hotkey.
Подписаться на:
Комментарии к сообщению (Atom)
Комментариев нет:
Отправить комментарий