Re: Return after AppActivate
- From: mr_unreliable <kindlyReplyToNewsgroup@xxxxxxxxxxx>
- Date: Thu, 20 Jul 2006 17:29:57 -0400
Frank, you have just discovered that appactivate+sendkeys can
be frustrating (at best) and frequently either useless or
downright dangerous (as in the case where your sendkeys
keystrokes can go to the wrong app and cause chaos).
To really do this right, you have to revert to using the
system api. What you do is get the handle of the window or
control (a child window of the parent window) and then use
sendmessage to send characters or mouse clicks to that
_specific_ window.
If that sounds too complicated, you could use the "BlockInput"
api, after warning your user, of course. The blockinput api
will block the users keystrokes and mouse input for the duration
it is in effect (which will hopefully be brief). After blocking
his input, you then do what you will with the other app, and then
turn off the blocking. If you would like to try this, search the vbScript archives -- I have posted the code several times.
As a third alternative, you can go to another scripting language,
such as AutoIt3 (the "beta" version), or FBSL (the Freestyle
Basic Scripting Language), both of which have the capability
(built into the language) of sending messages to a specific
window (or control) as suggested in the "api approach" paragraph
above.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
Frank Perry wrote:
Howdy,.
I need to control an open program and shut it down. I can do this using AppActivate() and SendKeys(). The problem is that if there is a user on a different application, his input winds up on my app when I switch. I need to keep his input out of the target program and restore the active app to the one that was active when I took control.
Is there a way to findout what application is active and get the ID so I can return control back to the user? Something like:
var ActiveApp = GetActiveApp() // the function I need
WshShell.AppActivate(MyApp)
WshShell.SendKeys("~")
WshShell.AppActivate(ActiveAPP)
- Prev by Date: Re: Looking for a script or a program to keep outlook running at all times....
- Next by Date: Re: Looking for a script or a program to keep outlook running at all times....
- Previous by thread: cscript sometimes fails to run JScript
- Next by thread: Re: Return after AppActivate
- Index(es):
Relevant Pages
|
Loading