</head> <body> <h1>SetMouseDelay</h1> <p>Sets the delay that will occur after each mouse movement or click.</p> <pre class="Syntax"><span class="func">SetMouseDelay</span>, Delay <span class="optional">, Play</span></pre> <h2 id="Parameters">Parameters</h2> <dl> <dt>Delay</dt> <dd><p>Time in milliseconds, which can be an <a href="../Variables.htm#Expressions">expression</a>. Use -1 for no delay at all and 0 for the smallest possible delay (however, if the <em>Play</em> parameter is present, both 0 and -1 produce no delay). If unset, the default delay is 10 for the traditional SendEvent mode and -1 for <a href="Send.htm#SendPlayDetail">SendPlay mode</a>.</p></dd> <dt>Play <span class="ver">[v1.0.43+]</span></dt> <dd><p>The word <em>Play</em> applies the delay to the <a href="Send.htm#SendPlayDetail">SendPlay mode</a> rather than the traditional Send/SendEvent mode. If a script never uses this parameter, the delay is always -1 for SendPlay.</p></dd> </dl> <h2 id="Remarks">Remarks</h2> <p>A short delay (sleep) is done automatically after every mouse movement or click generated by <a href="Click.htm">Click</a> and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a> (except for <a href="SendMode.htm">SendInput mode</a>). This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of mouse events.</p> <p>Due to the granularity of the OS's time-keeping system, delays might be rounded up to the nearest multiple of 10 or 15. For example, a delay between 1 and 10 (inclusive) is equivalent to 10 or 15 on most Windows XP systems (and probably 2k).</p> <p>A delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all. By contrast, a delay of -1 will never sleep.</p> <p>The built-in variable <strong>A_MouseDelay</strong> contains the current setting for Send/SendEvent mode. <span class="ver">[v1.1.23+]:</span> <strong>A_MouseDelayPlay</strong> contains the current setting for <a href="Send.htm#SendPlayDetail">SendPlay mode</a>.</p> <p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p> <h2 id="Related">Related</h2> <p><a href="SetDefaultMouseSpeed.htm">SetDefaultMouseSpeed</a>, <a href="Click.htm">Click</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="SendMode.htm">SendMode</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetControlDelay.htm">SetControlDelay</a>, <a href="SetWinDelay.htm">SetWinDelay</a>, <a href="SetBatchLines.htm">SetBatchLines</a></p> <h2 id="Examples">Examples</h2> <div class="ex" id="ExBasic"> <p><a class="ex_number" href="#ExBasic"></a> Causes the smallest possible delay to occur after each mouse movement or click.</p> <pre>SetMouseDelay, 0</pre> </div> </body> </html>