LockKbd – System Function**





LockKbd Function


Usage

The LockKbd function locks the keyboard. Even if LockKbd can be useful for preventing user interference while a script is running, we do not recommend using it. If something goes wrong, the only way to enable the keyboard again will be to power off!

Syntax

LockKbd

Remarks

Keystrokes are not transmitted during the execution of scripts. If you want to lock the keyboard and still be able to transmit keystrokes, see the example code below. Special combinations, such as <Ctrl <Alt <Del>>> or <Ctrl <Esc>>, are still active. When the last script finishes, the entire keyboard is reactivated.

Example

LockKbd

Example Code

Under Windows 2000/XP/2003, it is possible to call a Windows API function locking the keyboard using the WinTask External statement (not available in WinTask Lite). Below is a sample:

' Launch Notepad
Shell("notepad",1)

False = 0
True = 1

' Lock keyboard and mouse for 10 seconds
external("user32","BlockInput", True)
pause 5

' The script can still type
UseWindow("NOTEPAD.EXE|Edit|Untitled - Notepad|1",1)
SendKeys("aa")
pause 5

' Unlock keyboard and mouse - when the script ends,
' keyboard and mouse are unlocked even if an external call is not done.
external("user32","BlockInput", False)

' Check during 5 secs that you can now use mouse
pause 5