Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: sendkey sendkeysto Intcontrol(35, pacing problem IntControl(43, IntControl(36
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.
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) migh help you peer into the status bar.
Here's an example of a while loop checking for a window title:
while WinExist("Notepad") delay(2) endwhile
IntControl (35, 500, 0, 0, 0)to slow down sendkeys.
SKSpeed=100The 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
WinActivate('AlphaWorld') IntControl(36,'AlphaWorld',-1,0,0) Message("Autobuild begins","Go!") SendKey(`{UP}{UP}{UP}`)I never get an indication it is ready to receive input, this hangs until I break the script. SendKey doesn't seem to do anything, now I'm wondering if the two programs are even communicating.
I've played with polling the mouse and window positions and like that... but really don't want to head down that (much more difficult) road until I'm sure SendKeys can't be used, etc. Clues for me?
IntControl(43,0,0,0,0)
However *some* applications do something strange and the SendKey never occurs (and/or the IntControl 36 continues to wait)
The IntControl(43,0,0,0,0) disables the "wait till app is ready" stuff. THis means we cannot "pace" the sendkeys for you - so you have to add TimeDelays or other (usually better) pacing code to make sure the sendkeys don't get sent prematurely.
Article ID: W13843
Filename: Slow Sendkey and-or Process Control.txt
File Created: 1999:04:15:16:56:46
Last Updated: 1999:04:15:16:56:46