# #UseHook

Forces the use of the hook to implement all or some keyboard hotkeys.

#UseHook [On|Off]

#### Parameters

On|Off | #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).

#### Remarks

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. The exception to this is Windows 95/98/Me, upon which #UseHook is ignored (though the $ prefix works in a limited fashion).

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.

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. 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.

#### Related

#InstallKeybdHook, #InstallMouseHook, ListHotkeys

#### Example

    #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.
    #UseHook off
    #z::MsgBox, But not this one.