#InstallMouseHook - Syntax & Usage | AutoHotkey

AutoHotkey

#InstallMouseHook

Forces the unconditional installation of the mouse hook.

#InstallMouseHook

Remarks

The mouse hook monitors mouse clicks for the purpose of activating mouse hotkeys and facilitating hotstrings.

AutoHotkey does not install the keyboard and mouse hooks unconditionally because together they consume at least 500 KB of memory (but if the keyboard hook is installed, installing the mouse hook only requires about 50 KB of additional memory; and vice versa). Therefore, the mouse hook is normally installed only when the script contains one or more mouse hotkeys. It is also installed for hotstrings, but that can be disabled via #Hotstring NoMouse.

By contrast, the #InstallMouseHook directive will unconditionally install the mouse hook, which might be useful to allow KeyHistory to monitor mouse clicks.

You can determine whether a script is using the hook via the KeyHistory command or menu item. You can determine which hotkeys are using the hook via the ListHotkeys command or menu item.

This directive also makes a script persistent, meaning that ExitApp should be used to terminate it.

Related

#InstallKeybdHook, #UseHook, Hotkey, #Persistent, KeyHistory, GetKeyState, KeyWait

Example

#InstallMouseHook