Re: Return after AppActivate



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)

.



Relevant Pages

  • Re: Entwicklung von Unix-Anwendung mit C++ (m/w)/ NRW : Ref.-Nr.: 37302/1
    ... I am responsible for design and implementation of the persistent data server working with mySQL. ... Developed within very short time the product was successfully installed ... Reengineering and implementing a display tool for Experimental Physics Industrial Control System ... Developed an operator interface under X Window for High Energy Physics Accelerator Control System. ...
    (de.markt.arbeit.d)
  • Re: loosing messages leakes my app...
    ... It posts messages to a window, ... why don't you always use PostMessage? ... threads rely on the control, then you should not destroy the control before the ... POSSIBLY know the unique target window for which this is intended. ...
    (microsoft.public.vc.mfc)
  • Re: Owner Draw STATIC Window with XP Themes
    ... >> You should open a theme once per window... ... Each OpenThemeData has a matching CloseThemeData. ... say, "Well, CloseThemeData doesn't take an HWND, it takes only an HTHEME, so ... The following code sample demonstrates how to draw a button control. ...
    (microsoft.public.vc.mfc)
  • Re: Owner Draw STATIC Window with XP Themes
    ... >> You should open a theme once per window... ... Each OpenThemeData has a matching CloseThemeData. ... say, "Well, CloseThemeData doesn't take an HWND, it takes only an HTHEME, so ... The following code sample demonstrates how to draw a button control. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Repost for MS: UnsafeNativeMethods.CallWindowProc NullReferenc
    ... I'd be interested to analyse the dump also. ... Using the .NET Reflector to look at the Control ... > requires a valid window handle, ... > If you look at the implementation of NativeWindow, ...
    (microsoft.public.dotnet.framework.windowsforms)

Loading