Forces the use of the hook to implement all or some keyboard hotkeys.
#UseHook without one of the following words after it is equivalent to #UseHook 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 -- this one should not be positioned in the script as though it were a command (i.e. 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.
Hotkeys that use the keyboard hook cannot be triggered by means of the Send command. Similarly, mouse hotkeys cannot be triggered by the MouseClick command because all mouse hotkeys use the mouse hook. To work around this, use Gosub to jump directly to the hotkey's subroutine. For example: Gosub #LButton
If this directive does not appear in the script at all, it will behave as though set to OFF.
#InstallKeybdHook, #InstallMouseHook, ListHotkeys
#UseHook ; Force the use of the hook for hotkeys after this point.
#x::MsgBox, This hotkey will be implemented with the hook.
#y::MsgBox, And this one too.
#z::MsgBox, But not this one.