BlockInput
From AutoIt Wiki
Disables/enables mouse and keyboard input. Adapted from AutoIt docs.
Contents |
[edit] Syntax
BlockInput(flag)
[edit] Parameters
| flag | 1 = Disable user input. 0 = Enable user input. |
[edit] Return Value
Success: Returns 1.
Failure: Returns 0. Already Enable or #requireAdmin not used.
[edit] Example
If @OSVersion <> "WIN_98" And @OSVersion <> "WIN_ME" Then
BlockInput(1)
EndIf
Run("notepad")
WinWaitActive("[CLASS:Notepad]")
Send("{F5}") ;pastes time and date
BlockInput(0)
[edit] Remarks
If BlockInput is enabled, the Alt keypress cannot be sent.
The table below shows how BlockInput behavior depends on the Windows version; however pressing Ctrl+Alt+Del on any platform will re-enable input due to a Windows API feature.
| Operating System | "BlockInput" Results |
| Windows 95 | No effect. |
| Windows 98/Me | User input is blocked but AutoIt is also unable to simulate input. |
| Windows NT 4 (Without ServicePack 6) | No effect. |
| Windows NT 4 (With ServicePack 6) | User input is blocked and AutoIt can simulate most input. |
| Windows 2000 | User input is blocked and AutoIt can simulate most input. |
| Windows XP | User input is blocked and AutoIt can simulate most input. See exceptions below. |
| Windows Vista | User input is blocked and AutoIt can simulate most input if #requireAdmin is used. See exceptions below. |
If you are using Windows XP then you should be aware that a hotfix released between SP1 and SP2 limited BlockInput so that the Alt key could NOT be sent. This is fixed in XP SP2.
Note that functions such as WinMove() or Send() will still work when BlockInput is enabled because BlockInput just affects user interaction with the keyboard or the mouse not what is done with AutoIt functions (aside from the exceptions in the table above).
