/AutoHotkey.docset/Contents/Resources/Documents/commands/BlockInput.htm
HTML | 60 lines | 53 code | 7 blank | 0 comment | 0 complexity | 3a527463a5c2934a6fdab865b7e61015 MD5 | raw file
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>BlockInput</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <link href="../static/theme.css" rel="stylesheet" type="text/css" />
- <script src="../static/content.js" type="text/javascript"></script>
- </head>
- <body>
- <h1>BlockInput</h1>
- <p>Disables or enables the user's ability to interact with the computer via keyboard and mouse.</p>
- <pre class="Syntax">BlockInput, Mode</pre>
- <h3>Parameters</h3>
- <dl>
- <dt>Mode</dt>
- <dd><p><strong><u>Mode 1</u></strong>: One of the following words:</p>
- <p><strong>On</strong>: The user is prevented from interacting with the computer (mouse and keyboard input has no effect).</p>
- <p><strong>Off</strong>: Input is re-enabled.</p>
- <p><strong><u>Mode 2</u></strong>: This mode operates independently of the other two. For example, <code>BlockInput On</code> will continue to block input until <code>BlockInput Off</code> is used, even if one of the below is also in effect.</p>
- <p><strong>Send</strong>: The user's keyboard and mouse input is ignored while a <a href="Send.htm">Send</a> or <a href="Send.htm">SendRaw</a> is in progress (the traditional <a href="SendMode.htm">SendEvent mode</a> only). This prevents the user's keystrokes from disrupting the flow of simulated keystrokes. When the Send finishes, input is re-enabled (unless still blocked by a previous use of <code>BlockInput On</code>).</p>
- <p><strong>Mouse</strong>: The user's keyboard and mouse input is ignored while a <a href="Click.htm">Click</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="MouseClick.htm">MouseClick</a>, or <a href="MouseClickDrag.htm">MouseClickDrag</a> is in progress (the traditional <a href="SendMode.htm">SendEvent mode</a> only). This prevents the user's mouse movements and clicks from disrupting the simulated mouse events. When the mouse command finishes, input is re-enabled (unless still blocked by a previous use of <code>BlockInput On</code>).</p>
- <p><strong>SendAndMouse</strong>: A combination of the above two modes.</p>
- <p><strong>Default</strong>: Turns off both the <em>Send</em> and the <em>Mouse</em> modes, but does not change the current state of input blocking. For example, if <code>BlockInput On</code> is currently in effect, using <code>BlockInput Default</code> will not turn it off.</p>
- <p id="MouseMove"><u><strong>Mode 3</strong> (requires v1.0.43.11+)</u>: This mode operates independently of the other two. For example, if <code>BlockInput On</code> and <code>BlockInput MouseMove</code> are both in effect, mouse movement will be blocked until both are turned off.</p>
- <p><strong>MouseMove</strong>: The mouse cursor will not move in response to the user's physical movement of the mouse (DirectInput applications are a possible exception). When a script first uses this command, the <a href="_InstallMouseHook.htm">mouse hook</a> is installed (if it is not already). In addition, the script becomes <a href="_Persistent.htm">persistent</a>, meaning that <a href="ExitApp.htm">ExitApp</a> should be used to terminate it. The mouse hook will stay installed until the next use of the <a href="Suspend.htm">Suspend</a> or <a href="Hotkey.htm">Hotkey</a> command, at which time it is removed if not required by any hotkeys or hotstrings (see <a href="_Hotstring.htm">#Hotstring NoMouse</a>).</p>
- <p><strong>MouseMoveOff</strong>: Allows the user to move the mouse cursor.</p></dd>
- </dl>
- <h3>Remarks</h3>
- <p><strong>Note:</strong> <code>BlockInput On</code> might have no effect if UAC is enabled and the script has not been run as administrator. For more information, refer to the <a href="../FAQ.htm#uac">FAQ</a>.</p>
- <p>In preference to BlockInput, it is often better to use <code><a href="SendMode.htm">SendMode Input</a></code> or <code><a href="SendMode.htm">SendMode Play</a></code> so that keystrokes and mouse clicks become uninterruptible. This is because unlike BlockInput, those modes do not discard what the user types during the send; instead, those keystrokes are buffered and sent afterward. Avoiding BlockInput also avoids the need to work around sticking keys as described in the next paragraph.</p>
- <p>If BlockInput becomes active while the user is holding down keys, it might cause those keys to become "stuck down". This can be avoided by waiting for the keys to be released prior to turning BlockInput on, as in this example:</p>
- <pre>^!p::
- KeyWait Control <em>; Wait for the key to be released. Use one KeyWait for each of the hotkey's modifiers.</em>
- KeyWait Alt
- BlockInput On
- <em>; ... send keystrokes and mouse clicks ...</em>
- BlockInput Off
- return</pre>
- <p>Input blocking is automatically and momentarily disabled whenever an ALT event is sent (then re-enabled afterward).</p>
- <p>When BlockInput is in effect, user input is blocked but AutoHotkey can simulate keystrokes and mouse clicks. However, pressing Ctrl+Alt+Del will re-enable input due to a Windows API feature.</p>
- <p>Certain types of <a href="_UseHook.htm">hook hotkeys</a> can still be triggered when BlockInput is on. Examples include <code>MButton</code> (mouse hook) and <code>LWin & Space</code> (keyboard hook with explicit prefix rather than modifiers <code>$#</code>).</p>
- <p>Input is automatically re-enabled when the script closes.</p>
- <h3>Related</h3>
- <p><a href="SendMode.htm">SendMode</a>, <a href="Send.htm">Send</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></p>
- <h3>Example</h3>
- <pre class="NoIndent">BlockInput, on
- Run, notepad
- WinWaitActive, Untitled - Notepad
- Send, {F5} <em>; pastes time and date</em>
- BlockInput, off</pre>
- </body>
- </html>