Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Activate Shell Window (ShellExecute?) 1

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
Hallo. I have launched an application in a shell & I can send it keystrokes (although the Sleep() function seems to mess about with that - do it on a timer, I guess).
All I need to do now is to be able to set the application's window to active before I send keys.
Is there a special command I need for this? Or just another way of using ShellExecute (I can't see anywhere in there to pass the shelled exe's handle in)?

Any & all help...

Cheers,
Douglas JL

If it don't make you laugh, it ain't true.
 
If you can't do it with ShellExecute then look at CreateProcess. This is more complex but you can pass parameters that tell whether to inherit handles or not among other things. Look at faq101-1954 for starters. Also look at MSDN, Borland's MS SDK help files, and C++ Developer's Journal (was Reisendorf Purblishing but now Bridge's Publishing at ). James P. Cottingham

When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour. That's relativity.

[tab][tab]Albert Einstein explaining his Theory of Relativity to a group of journalists.
 
That could be an answer, but I already have the handle from ShellExecute. What I can't seem to do (either with SetActiveWindow or SetActiveWindow) is get control to pass to the window I've called.
Driving me nuts!

Cheers,
Douglas JL

If it don't make you laugh, it ain't true.
 
Will this work?
Code:
ShowWindow(TheWindowsHandle, SW_SHOW);

Try this:
Code:
HWND it = FindWindow(NULL, "Window Caption");
// Or get it via shellexecute
BringWindowToTop(it);
[Thanks in advance|Hope I helped you]
Exodus300
World-Wide Alliance of Evil and Twisted People
[red]"Experimentation by Example is the best learning tool" - Exodus300[/red]
Code:
if (pop_tarts == 0)
{
   tantrum = 1;
}
[pc3]
 
Cheers, man - I tried it, but still can't get the window to become active.
Could it be for any of the following reasons?
I still want to run code in the background app (to pass keystrokes to the active window) - perhaps this is screwing the active setting? I found that the Sleep() command screws around with this, so am not using it, now.
I'm running the app in NT4.

I've tried BringToTop, SetActiveWindow, SetForegroundWindow... Basically everything I can think of. Perhaps the answer would be in another call to ShellExecute, one that just calls an open file. I admit, though, that I can't see how.

Douglas JL

If it don't make you laugh, it ain't true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top