

Timers are useful because they run asynchronously, meaning that they will run at the specified frequency (interval) even when the script is waiting for a window, displaying a dialog, or busy with another task. To change the priority of an existing timer without affecting it in any other way, leave the parameter before this one blank. This optional parameter is an integer between -21474836483647 (or an expression) to indicate this timer's thread priority. Its absolute value must be no larger than 4294967295 ms (49.7 days).ġ) the timer does not exist: it will be created with a period of 250.Ģ) the timer already exists: it will be enabled and reset at its former period unless a Priority is specified. Period must be an integer, unless a variable or expression is used, in which case any fractional part is ignored. This allows the object to be freed if the script is no longer referencing it, but it also means the timer's Period and Priority are not retained. : If Label is an object created by the script (not an actual function or label), the timer is automatically deleted after the timer function returns, unless the timer was re-enabled. For example, specifying -100 would run the timer 100 ms from now then disable the timer as though SetTimer, Label, Off had been used. : If Period is negative, the timer will run only once. If Period is positive, the timer will automatically repeat until it is explicitly disabled by the script.It can be set to repeat automatically or run only once: The timer will be automatically enabled and reset. Period: Creates or updates a timer using the absolute value of this parameter as the approximate number of milliseconds that must pass before the timer is executed. Turning off a timer does not release the object. If the timer is associated with a function object, the object is released. If the timer exists but was previously set to run-only-once mode, it will again run only once.ĭelete : Disables and deletes an existing timer.

If the timer doesn't exist, it is created (with a default period of 250). On: Re-enables a previously disabled timer at its former period. This parameter must be either given a non-empty value or completely omitted. Note: : Passing an empty variable or an expression which results in an empty value is considered an error. Other expressions which return objects are currently unsupported. For example, SetTimer %FuncObj%, 1000 or SetTimer % FuncObj, 1000. : If not a valid label name, this parameter can be the name of a function whose parameter list has no mandatory parameters (see the function example), or a single variable reference containing a function object. This is useful for timers which launch functions or function objects. : If A_ThisLabel is empty but the current thread was launched by a timer, that timer is used.
#Work timer windows update
For example, SetTimer, Off can be used inside a timer subroutine to turn off the timer, while SetTimer, 1000 would either update the current timer's Period or set a new timer using the label which is currently running. : If Label is omitted, A_ThisLabel will be used. As with the parameters of almost all other commands, Label can be a variable reference such as %MyLabel%, in which case the name stored in the variable is used as the target. The name of the label or hotkey label to which to jump, which causes the commands beneath Label to be executed until a Return or Exit is encountered. SetTimer, Label, PeriodOnOffDelete, Priority Parameters Label SetTimer - Syntax & Usage | AutoHotkey SetTimerĬauses a subroutine to be launched automatically and repeatedly at a specified time interval.
