Installs or uninstalls the mouse hook.

InstallMouseHook Install, Force



Type: Boolean

Omit this parameter or pass true (any non-zero, non-blank value) to require that the hook be installed. Pass false to remove any requirement previously set by this function and potentially uninstall the hook.


Type: Boolean

If Force is true and Install is omitted or true, the hook is uninstalled and reinstalled. This has the effect of giving it precedence over any hooks previously installed by other processes. If the system has stopped calling the hook due to an unresponsive program, reinstalling the hook might get it working again.

If Force is true and Install is false, the hook is uninstalled even if needed for some other purpose. If a hotkey, hotstring or InputHook requires the hook, it will stop working until the hook is reinstalled. The hook may be reinstalled explicitly by calling this function, or automatically as a side-effect of enabling or disabling a hotkey or calling some other function which requires the hook.

If Force is false, an internal variable is updated to indicate whether the hook is required by the script, but there might be no immediate change if the hook is required for some other purpose.


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 function can be used to unconditionally install the mouse hook, which has benefits including:

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

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


Installs the mouse hook unconditionally.