Displays script info and a history of the most recent keystrokes and mouse clicks.

Command  Example:KeyHistory
Function Example:KeyHistory()


This command is equivalent to selecting the "View->Key history" menu item in the main window.

To disable key history, specify the following line anywhere in the script:

#KeyHistory 0

#KeyHistory can also be used to change the maximum number of events that will be displayed.

This feature is intended to help debug scripts and hotkeys. It can also be used to detect the scan code of a non-standard keyboard key using the steps described at the bottom of the key list page (knowing the scan code allows such a key to be made into a hotkey).

The virtual key (VK) of the wheel events (WheelDown, WheelUp, WheelLeft, and WheelRight) are placeholder values that do not have any meaning outside of AutoHotkey. Also, the scan code for wheel events is actually the number of notches by which the wheel was turned (typically 1).

If the script does not have the keyboard hook installed, the KeyHistory window will display only the keyboard events generated by the script itself (i.e. not the user's). If the script does not have the mouse hook installed, mouse button events will not be shown. You can find out if your script uses either hook via "View->Key History" in the script's main window (accessible via "Open" in the tray icon). You can force the hooks to be installed by adding either or both of the following lines to the script:



#KeyHistory, #InstallKeybdHook, #InstallMouseHook, ListHotkeys, ListLines, ListVars, GetKeyState, KeyWait, A_PriorKey


KeyHistory ; Display the history info in a window.