I´m started learning C# and now I´m wondering if there is a way to start a third-party-application without stealing focus or just always display the windows of this application/process in the background.
To be more specific: I have written an application that can start a Steam-Client with parameters like login-data. As far as I know the Steam-Client is written in Java and maybe thats one of my problems. I also know that you can start the Steam-Client in "Silent-Mode" like this:
"C:\Programs\Steam\Steam.exe" -silent -login user password
But this won´t help if I don´t want the Steam-Client to steal the focus. There are two windows that appear in the foreground: Login-Window and Loading-Window.
I searched on stackoverflow and with google for a solution, but none worked for me. One possible solution would be, but doesn´t work for me:
Process startsteam = new Process();
startsteam.StartInfo.FileName = cursteampath;
startsteam.StartInfo.Arguments = "-silent -login " + user + " " + password;
startsteam.StartInfo.CreateNoWindow = true;
startsteam.StartInfo.ErrorDialog = false;
startsteam.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
startsteam.Start();
Like I wrote before, this wouldn´t hide the Login-Window(Form) and the Loading-Window. I also noticed that Steam is starting subprocesses like steamwebhelper.exe
.
My question is: Is there any way in C# to start a process of a third-party-application and prevent it and its sub-processes from stealing focus or just force all windows to display in the background?
Edit: This solution also doesn´t work for me stackoverflow user32.dll