Function Reference


BlockInput

Disable/enable the mouse and keyboard.

BlockInput ( flag )

Parameters

flag 1 = Disable user input
0 = Enable user input

Return Value

Success: Returns 1.
Failure: Returns 0. Already Enable or #requireAdmin not used.

Remarks

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 2000 User input is blocked and AutoIt can simulate mouse and keyboard input.
Windows XP User input is blocked and AutoIt can simulate mouse and keyboard input. See remarks below for an issue with Windows XP SP1.
Windows Vista User input is blocked and AutoIt can simulate mouse and keyboard if #RequireAdmin is used.

A Windows hotfix was released for Windows XP SP1 that contained a bug that prevents the Alt keystroke from being sent (via the Send() function) while BlocKInput() is active. The Windows bug is fixed in Windows XP SP2 and newer.

BlockInput() only affects user-input. Input from functions like Send() or MouseMove() still work.

Related

Send

Example


BlockInput(1)

Run("notepad.exe")
WinWaitActive("[CLASS:Notepad]")
Send("{F5}") ; Pastes the date and time

BlockInput(0)