#SingleInstance

AutoHotkey

#SingleInstance

Determines whether a script is allowed to run again when it is already running.

#SingleInstance [force|ignore|off]

Parameters

force|ignore|off

This parameter determines what happens when a script is launched while a previous instance of itself is already running:

The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

The word IGNORE skips the dialog box and leaves the old instance running. In other words, attempts to launch an already-running script are ignored.

The word OFF allows multiple instances of the script to run concurrently.

If the parameter is omitted, a dialog box is displayed asking whether to keep the old instance or replace it with the new one.

Remarks

A script containing hotkeys, hotstrings, #Persistent, OnMessage(), or Gui is single-instance (dialog & prompt) by default. Other scripts default to allowing multiple instances. This behavior can be disabled or modified as described above.

This directive is ignored when any of the following command line switches are used: /force /f /restart /r

Related

Reload, #Persistent

Example

#SingleInstance force
#SingleInstance ignore
#SingleInstance off