Yesterday while debugging my AutoHotkey script, I accidentally triggered an endless loop of MouseMove
and MouseClick
events. Every 0.5 seconds my mouse would click random parts of the screen.
After unsuccessfully trying to terminate AHK with the task manager, I ended up turning off my computer to end the script.
How can I stop an active AutoHotkey script?
Click the "Stop Script" button to stop the script from running. Stopping the script can prevent the browser from running out of memory or crashing. If this problem is only happening on one page and every other page is fine, a script on that one page is likely causing your problem.
If you ever want to stop AutoHotKey from blocking any keys, select the “Suspend Hotkeys” option. Your AutoHotKey's tray icon will change from an “H” to an “S” to indicate that hotkeys are being blocked. To re-enable all hotkeys, repeat this same action again.
The most reliable method of ending an active script is to pre-emptively include an emergency ExitApp
hotkey. A common practice is to place the following at the bottom of any script.
Esc::ExitApp ; Exit script with Escape key
You can also set hotkeys to pause, suspend, or reload your script.
^!p::Pause ; Pause script with Ctrl+Alt+P ^!s::Suspend ; Suspend script with Ctrl+Alt+S ^!r::Reload ; Reload script with Ctrl+Alt+R
On Windows 10/8/7/Vista, you can quickly log off with the keyboard shortcut Ctrl+Alt+Delete, followed by Alt+L.
This is because pressing Ctrl+Alt+Delete opens a special window which cannot be manipulated by programs like AutoHotkey.
If you have control of the keyboard and mouse, you can end the script by right-clicking AutoHotkey's green H icon in the taskbar and selecting "Exit"
For a more generic solution, AHK user None wrote AHKPanic()
, a method which can pause, suspend, or kill all other running scripts. (Optionally ends the script that called it)
AHKPanic(Kill=0, Pause=0, Suspend=0, SelfToo=0) { DetectHiddenWindows, On WinGet, IDList ,List, ahk_class AutoHotkey Loop %IDList% { ID:=IDList%A_Index% WinGetTitle, ATitle, ahk_id %ID% IfNotInString, ATitle, %A_ScriptFullPath% { If Suspend PostMessage, 0x111, 65305,,, ahk_id %ID% ; Suspend. If Pause PostMessage, 0x111, 65306,,, ahk_id %ID% ; Pause. If Kill WinClose, ahk_id %ID% ;kill } } If SelfToo { If Suspend Suspend, Toggle ; Suspend. If Pause Pause, Toggle, 1 ; Pause. If Kill ExitApp } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With