Hi,

I am trying to automate a gui application by using 'wshshell.sendkeys'.
What I want to do (if possible) is load the app and wait for a window to
become active in the app, then execute some 'sendkeys' commands. I have used
autoit before and I know that works, but I want VBscript to do it. Is this
possible??

Thanks
--
Firewalker82

Re: reference / manage application windows with vbscript by mr_unreliable

mr_unreliable
Tue Jul 08 11:24:41 CDT 2008

Firewalker82 wrote:
> What I want to do (if possible) is load the app and wait for a window to
> become active in the app, then execute some 'sendkeys' commands.

hi Firewalker,

Yes, you can do this with vbScript, but...

First off, launch your app with the shell.run method. Then use
appactivate AS A FUNCTION. It will return false if your app has
not appeared yet (finished loading). When the app window appears,
then appactivate will return true. At that point you can start
sending keys. Some apps don't accept keystrokes until a fraction
of a second after they finish loading. Also some apps don't accept
a "blast" of keystrokes (a long string), but rather expect the
keys to come one-at-a-time, as though somebody was actually typing
stuff in. And so, you sometimes have to play around with the
sleep method, to get your app to accept the keystrokes you send.

All that being said, appactivate and sendkeys is not very reliable.
The keystrokes will go to the app with focus, and any number of
apps can pop up to steal the focus away from your target app
(e.g. im, av updates, and any number of other things). So it will
frequently happen that your keystrokes will land on some other
focus-stealing app, with undesired, unfortunate or even disastrous
consequences.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)