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.

Pacing Problems and Process Control

Keywords: sendkey sendkeysto Intcontrol(35,   pacing problem

Question:

I am trying to use WinBatch in Windows 95 as a replacement for the old window recorder from windows 3.1. I am using with lotus 97 and Pcomm, when I playback a .wbt file, it plays back too fast for my system to keep up with it. How do I slow down the playback, almost to recorded speed?

Also, I need WinBatch to wait for the application to finish a process before issuing another function (key stroke like Alt-F ...). My application retrieves and processes data that may take up to 90 mins. I have tried various methods but it will always try and issue the keystrokes before the process is complete. I have had to reply on time delays statements of up to 90 mins. The actual amount of time varies daily and I would rather not wait for 90 mins for this one part and another 15 for the next. There must be a better way to "not" issue another command until the "Busy" ends.

Answer:

The IntControl(35,...) function can modify playback speed (see below). However, WinBatch is not really a recorder type product.

The basic technique requires sending some keystrokes and then waiting for an event to occur, then sending more keystrokes.

You can slow it down with TimeDelay between sequences of keystrokes, but it usually results in a slow running script.

This is called the "pacing" problem, and each solution is different. Each application generally requires its own solution.

With 32 bit WinBatch against 32 bit applications, we try to take care of most of the pacing problems for you, but we can't do everything. Figure out where the script fails (usually by getting ahead of the application) and then figure out how to slow it down or wait for some event at that point.

The idea is to use stuff like WinWaitExist and WinWaitChild for windows to appear in response to keystrokes and use that for timing - or WinExist or WinExistChild to see when windows disappear.

Basically you have to be able to tell when the application is done.

What does it do? What is the task?

If it is creating files, we can watch the files being created to tell when it is done.

Is it printing? We can watch the print spool.

Does it put up or take down a window? We can watch the windows. Does it put text on the status bar - we *might* be able to see the text.

There are other techniques, like waiting for files to come into existence and then to have a non-zero byte count. Depends. To check for files, use FileExist and FileSize. A file that has a filesize of 0 is often still being worked on.

The Control Manager extender (on the website) might help you peer into the status bar.

Solutions:

Here are some things you can do to test and debug.
  1. Run in Debug mode. If it works properly when you have to push NEXT to go through each statement, then it is most definitely a timing problem.
  2. Use the TimeDelay command to slow sendkey. However, the drawback is that the time interval must be specified.
  3. Create a loop which is tracking an event in the program. Things you can check for: files that exist, windows, dialog boxes, system resource usage, etc. For example, a dialog box may be displayed when printing is in progress. Write a loop in the script which checks for the existence of the dialog box. When the dialog box closes the script will continue.

    Here's an example of a while loop checking for a window title:

    		while WinExist("Notepad")
    			delay(2)	
    		endwhile	
    
  4. In 32 bit versions of WIL, there is also an IntControl(35,...) function which will slow sendkey down in the 32 bit version: IntControl(35,p1,0,0,0). So you could put something like the following at the top of your script:
    	IntControl (35, 500, 0, 0, 0)
    
    to slow down sendkeys.
  5. In 16-bit WinBatch: add a setting to the WWWBATCH.INI. Add the following line to the [Main] section of WWWBATCH.INI:
     
    	SKSpeed=100
    
    The default value is 50, which is the delay (in milliseconds) between key presses and releases. 50 ms = 10 cps. The higher the value, the slower it is.

    Or, have WinBatch make the change on the fly for you, with:

    	in = IniReadPvt("Main","SKSpeed","","WWWBATCH.INI")
    	if in != "100"
    		IniWritePvt("Main","SKSpeed","100","WWWBATCH.INI")
    	EndIf
    

Article ID:   W12706
Filename:   Pacing Problems and Process Control.txt
File Created: 1999:04:15:16:49:04
Last Updated: 1999:04:15:16:49:04