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.

Make Sendkey Work with Debug

Keywords: 	 sendkey and debug

Question:

In an early 16 bit version of WinBatch, executing a Sendkey command with the Debug window open would send the keystrokes to whatever window would have been active if the Debug window had not appeared. Somewhere along the line this got changed so the keystrokes go to the Debug window instead. This means that if you think you might use Debug, you have to use SendKeysTo instead of Sendkey. The problem with SendKeysTo is that when Debug is not running, SendKeysTo will reactivate a window which is already active. This can cause annoying display flashing. Not only that, but in the case of software that is not always ready to accept keystrokes immediately after activation, keystrokes can be lost. Another problem this Debug behaviour causes is when an action is performed that produces (or potentially produces) a new window. If you use the WinGetActive command to wait until a certain window is active, you will wait forever because Debug is the active window. If you wait until a certain window is no longer the active one (meaning a new window has appeared), your wait will end immediately.

It would be nice to have the Debug function work the way it used to. That way you could step through Sendkey commands and wait loops as easily as any other parts of your code.

Answer:

What you say is true. But there was some technical difficulty (that I forgot the details of) that prevented us from doing that. SendKeysTo is all we have working with Debug. However we have created a new debug function called DebugTrace, that can get around this issue altogether. DebugTrace creates and writes a line by line debugging file of each statement executed in a script.
Article ID:   W13837
Filename:   Sendkey and Debug Function.txt
File Created: 2001:01:05:13:29:18
Last Updated: 2001:01:05:13:29:18