End script task, pause, exit
You can end a running script task in several ways.
Click the End task toolbar button or menu command.
If the script adds a tray icon, right-click it and select End task.
If the script calls script.setup like this at the start, press the exit key. If UAC blocks it, try with
Alt
,Ctrl
orWin
.
script.setup(trayIcon: true, exitKey: KKey.MediaStop);
- If the script calls script.setup like this at the start, press the
Sleep
button on the keyboard.
script.setup(trayIcon: true, sleepExit: true);
- Press
Win+L
orCtrl+Alt+Delete
. If the script calls script.setup like this at the start, it will end immediately. Else it will end when calling a keyboard or mouse input function or wnd.Activate, because these functions then fail and throw exception; some other functions too.
script.setup(trayIcon: true, lockExit: true);
- Insert script.pause in loops etc, in places safe to pause or end the script. To end the script, press the pause key (default
ScrollLock
), and then use any of the above ways to end the paused script.
script.pause();
Changing the pause key.
script.setup(trayIcon: true, sleepExit: true, pauseKey: KKey.MediaPlayPause);
- A script can call script.end to end another script. For example you can add a trigger with this action code.
script.end("Script name.cs");
- A script can set a trigger to end itself.
using Au.Triggers;
run.thread(() => {
ActionTriggers Triggers = new();
Triggers.Hotkey["?+F1"] = o => { script.end(); };
Triggers.Run();
});
dialog.show("Main script code");
See also: return, exit, throw exception.