Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Highlight a minimized App
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00697567
Message ID:
00698224
Views:
14
>Ed, I have the wsh script running,but it will only show if the app is not mimimized.
>
>Is there a way to show the app if it is running minimized?
>

Gerard,

This is not going to be a popular reply, but it needs to be said. You're trying to approach the problem in the completely wrong fashion here. You face a terrible problem attempting to manipulate anonymous things running in the operating system, often by their visible Windows. Instead of this anonymity, you should be looking for a way to create a causal link between those OS processes your app launches and you application. And the way to do that is to not use anonymity.

You face the problem of find the hWnd of a given process's main Window by name, even when that may not provide suitable identity. That's a good observation - what the executable is does not provide sufficient granularity to manipulate the external tasks the way you'd like. Time to find another way.

Each process that gets launched has its own unique identifier that references it. Wouldn't it be nice to record that moniker somehow, and then use it to do what you want?

(I'll assume the answer is yes.) VFP's RUN command doesn't do this for you. ShellExecute() gives us back pseudohandles that identify whether a process was started, but gives us no handle on the process's progress. Wscript.Shell gives us a firm grip on a single running application, but only if launched modally. What to do?

Enter API_APPRUN...a class which is used to run executables from within VFP in a modal or non-modal fashion. It is able to track whether or not a process is running at any given moment...sounds like a solution!

API_APPRUN relies on the native OS CreateProcess() API call. This is documented in the code and in the referenced MSDN docs, as well as a lot of other places (not in the VFP realm.) CreateProcess() tracks both the process and it's initial thread by both id and handle - and these can be used to check whether a window belongs to a given process, or to terminate a process without even the need to find a window. Simply create a API_APPRUN object, use it to run a given app, and then use the object to see if it's still running, what its process id and handle are, and if necessary to blow it out of the water without a secod thought. As long as you haven't tossed away the API_APPRUN object, you have gthe non-anonymous capability you need.

Isn't this a better way to handle your problem than by trying to winkle which of 12 identical twins is the one you want to terminate?
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform