Launch External Program in Background?

Blitz3D Forums/Blitz3D Programming/Launch External Program in Background?

Roland(Posted 2006) [#1]
Hey all,

I've seen a few snippets in the code archives & done a little searching on WIN32 functions, etc., but I figured it would give me a headstart to see if anyone else has had to tackle something similar...

Is it possible to launch another program from blitz and run it in the background? (minimized, or something like that?) It would be best for my purposes if the blitz window didn't even lose focus, or regained it quickly, staying in the foreground.

I'd also like to be able to close the window after a period of time, or recognize when it closes by itself.

any ideas?

thanks,
roland


Picklesworth(Posted 2006) [#2]
I wrote a DLL a while ago, using C++, which launches a program and tells you when it's been closed.
http://www.blitzbasic.com/toolbox/toolbox.php?tool=151
It is also possible to very easily use the same technique to find its window handle, (window handle is stored in the exact same object which is accessed to find application handle) which could be used to minimize it in a way that does not have a high potential of failing due to differences in people's computers.
(In fact, it would work 99.9% of the time!)
The Blitz window can be told to regain focus with the following untested code snippet using user32.decls:
blitzhWnd=SystemProperty("AppHWND")
api_SetFocus(blitzhWnd)


I'll send you the source code to that DLL so you can change it, if you want :)
(Or maybe I'll do those changes soon, anyway... no promises, though!).


@rtur(Posted 2006) [#3]
Mr. Picklesworth
Can you email sources to me too?
mail@...

Thanks!


Roland(Posted 2006) [#4]
Wow, that looks really great Mr. Picklesworth. Thanks for the reply! I'd be delighted if you would send me the source code -- hopefully it's not too far over my head :)

Let me know if you do end up updating the DLL yourself. And thanks again for the excellent info! It looks like this might be just what the doctor ordered.

best,
roland