WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sending Keystrokes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

IgnoreInput is Ignoring SendKey

 IgnoreInput Sendkey Sendkeysto BlockInput lock workstation

Question:

How do I simulate IgnoreInput function in 32 bit WinBatch? I want user interaction to be prevented during SendKeying predefined answers to setup windows, etc.

Answer:

In versions of Winbatch prior to 2002B, IgnoreInput does not work in 32 bit Windows. This was beyond Winbatch's control in Windows 95 and NT4, both of which OS's prevented Winbatch from locking down the system.

However, in Winbatch 2002B, IgnoreInput is now supported on Windows 98/ME/2000/XP. (It will not work on 95 or NT4.) It will return -1 if run on an unsupported platform. Also you can now specify a "flag" of -1 to query the current state.


For users who don't have 2002B, a user came up with the following DllCall that makes a call to the BlockInput function. The code will disable the keyboard / mouse. It's a real API gem when one must use SendKey and keep the user from messing it up as the script runs.

BlockInput blocks input except if Winbatch is waiting for input. And Ctrl-Alt-Del cancels the BlockInput, to get back input.

The BlockInput function under different OSes has the following behavior:
Under Win95b and NT 4.0 workstation, it returns the error "1301: DllCall: Bad Entrypoint name". It works fine on Win98se, Win2000pro, and WinXPpro.

Blocking CTRL-ALT-DELETE on NT4 or W2K is a security risk, because it could cause not being able to log on any more. Under Win2000, with the BlockInput you can still CTRL+ALT+DEL and get back keyboard and mouse control.

You can work around the ctrl-alt-del issue on nt/w2k boxes by throwing the right registry switches to turn off the options in the ctrl-alt-del box. This way the user COULD hit ctrl-alt-del, but everything would be greyed out if they did, so it was useless to them. Of course the problem with this method is if your script crashes or something happens, then someone will have to go into the registry and put those back again!

;action=@TRUE
;action=@FALSE
#DefineFunction BlockInput(action)
sDLLName = StrCat(DirWindows(1), "User32.DLL")
result = DLLCall(sDLLName, long:"BlockInput", long:action)
Return result
#EndFunction
Here is the Microsoft MSDN reference to the BlockInput function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/keybinpt_5kxg.asp
This reference gives more information about what cancels BlockInput and the supported operating systems.

Question regarding IgnoreInput in 16-bit Winbatch:

Sendkey is now being ignored when using IgnoreInput. Why?

Answer:

From WinBatch version 4.0L to version 5.0, IgnoreInput changed. In the older versions of WinBatch, when you sent a keystroke to an application, IgnoreInput would allow those keystrokes to pass through. In newer versions since version 5.0, WinBatch was able to emulate keystrokes so successfully that IgnoreInput now ignores all keystrokes, even those sent by WinBatch.

In the versions of Winbatch from version 5.0 to the last release of the 16-bit version (97D), the SendKey function works so well that, in fact, the operating system cannot tell if it is really the keyboard or not. The result is that Windows ignores the keyboard if IgnoreInput is set. So in those versions of Winbatch, IgnoreInput ignores everything, including SendKey and SendKeysto. (This demonstrates just how good our SendKey emulation of the keyboard really is.)

To get around this in the 16 bit version of Winbatch, you need to turn IgnoreInput off before the keystroke is sent, and then reinitialize it (turn it back on) after the keystokes are sent.


Article ID:   W13825
Filename:   IgnoreInput is Ignoring SendKey.txt
File Created: 2002:02:21:13:59:32
Last Updated: 2002:02:21:13:59:32