Forces the use of the hook to implement all or some keyboard hotkeys.
#UseHook OnOff
Specify one of the following words (if omitted, it defaults to On):
On: The keyboard hook will be used to implement all keyboard hotkeys between here and the next #UseHook OFF
(if any).
Off: Hotkeys will be implemented using the default method (RegisterHotkey() if possible; otherwise, the keyboard hook).
Normally, the windows API function RegisterHotkey() is used to implement a keyboard hotkey whenever possible. However, the responsiveness of hotkeys might be better under some conditions if the keyboard hook is used instead.
Turning this directive ON is equivalent to using the $ prefix in the definition of each affected hotkey.
As with all # directives -- which are processed only once when the script is launched -- #UseHook
should not be positioned in the script as though it were a command (that is, it is not necessary to have it contained within a subroutine). Instead, position it immediately before the first hotkey label you wish to have affected by it.
By default, hotkeys that use the keyboard hook cannot be triggered by means of the Send command. Similarly, mouse hotkeys cannot be triggered by commands such as Click because all mouse hotkeys use the mouse hook. One workaround is to use Gosub to jump directly to the hotkey's subroutine. For example: Gosub #LButton
.
[v1.1.06+]: #InputLevel and SendLevel provide additional control over which hotkeys and hotstrings are triggered by the Send command.
If this directive does not appear in the script at all, it will behave as though set to OFF.
Like other directives, #UseHook cannot be executed conditionally.
#InstallKeybdHook, #InstallMouseHook, ListHotkeys, #InputLevel