Function Reference


BlockInput

Disable/enable the mouse and keyboard.

BlockInput ( flag )

Parameters

flag $BI_DISABLE (1) = Disable user input
$BI_ENABLE (0) = Enable user input

Constants are defined in "AutoItConstants.au3".

Return Value

Success: 1.
Failure: 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 XP User input is blocked, AutoIt can simulate mouse and keyboard input.
Windows Vista and above User input is blocked if #RequireAdmin is used, AutoIt can simulate mouse and keyboard input.

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

Related

Send, ControlSend, MouseMove

Example

#RequireAdmin
#include "Extras\HelpFileInternals.au3"
#include <AutoItConstants.au3>
Example()
Func  Example()
; Run Notepad
Run ("notepad.exe")
; Wait 10 seconds for the Notepad window to appear.
Local $hWnd= WinWait ("[CLASS:Notepad]","",10)
; Retrieve the control that has keyboard focus in Notepad.
Local $sEditControl= ControlGetFocus ($hWnd)
; Disable user input from the mouse and keyboard.
BlockInput ($BI_DISABLE)
; typing have not effect
; Wait for 2 seconds.
Sleep (2000)
; Send the 'F5' key to the edit control of Notepad to display the date and time.
; The handle returned by WinWait is used for the "title" parameter of ControlSend.
; the controlSend will be honored even if the BlockInput() is disable
ControlSend ($hWnd,"",$sEditControl,"{F5}")
; Enable user input from the mouse and keyboard.
BlockInput ($BI_ENABLE)
; typing has effect
; Wait for 2 seconds to test if input is enable
Sleep (4000)
  _NotepadForceClose($hWnd)
EndFunc ;==>Example

AltStyle によって変換されたページ (->オリジナル) /