Groups | Blog | Home
all groups > c# > october 2007 >

c# : setting foreground window when no user is actively logged in


Family Tree Mike
10/18/2007 7:01:12 PM
Stephan,

I guess I am missing something obvious, but how is the console application
started if the screen is locked? In other words, no one would be able to
type or run the console application, right?

[quoted text, click to view]
Stephan Steiner
10/18/2007 10:48:30 PM
Hi

I need to start a GUI application from a console app. Upon startup, the
application can display one or two popups, which need clicking away. I have
all this handled using FindWindow, GetDLGCtrlID and PostMessage respectively
(find window, find control ID of the button that needs pressing, and press
the button).

However, the software in question will only bring up the popup if it is in
the foreground. So I'm using GetForegroundWindow to find the window that
currently has focus, and if it's not the one I need to have focus, I call
SetForegroundWindow to give the proper window focus.

So far, everything is still good. However, now, the app needs to keep on
running if no user is in front of the computer. And as soon as the screen is
locked, SetForegroundWindow does nothing.. so the app starts minimized and
remains so and the popup never comes up - and thus the application never
starts up properly. Is there a way to bring an application in front even if
the screen is locked (we assume some interactive user is logged in.. we're
not looking at a situation where there's no active user session ).

Regards
Stephan

Stephan Steiner
10/19/2007 2:37:03 PM
Here's how it works - the machine is set up to automatically log in a user
upon startup, and then launch the application.

For now, after the machine is started, a user logs in, and starts the
application manually. As long as you don't log out again, the application
keeps on running. Once that works we'll look at running the cli app from a
service.. we'll see if it works but eve nif it doesn't, we can still use the
approach described above.

Regards
Stephan
"Family Tree Mike" <FamilyTreeMike@discussions.microsoft.com> wrote in
message news:D20D6EBF-4873-4FDA-A673-E10A60F9D7EB@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button