winapi - Starting a process without stealing focus (C#) -


I should be able to initiate the process to steal the focus (both console and windowed) without the net framework that I This is the only way within Microsoft.VisualBasic.AppWinStyle to get what Microsoft.VisualBasic.Interaction.Shell got to do. [Small | Normal]. NoFocus (which is being passed to SW_SHOWMINNOACTIVE / SW_SHOWMA ShellExecute map)

In the current version of my code (which steals the focus), I am using System.Diagnostics.Process, and The functionality that gives me, which relies on some of the interaction.Shell method is not. 2 questions (I do not really get a good answer by removing a serious and frustrating disappointment)

1) Am I right that I have no choice, but wrap CreateProcess or ShellExecuteEx myself, or am I missing some other solution? I was really hoping to avoid this, because this process is a complete and useful cover other than this inspection, and a lot of functionality for implementation, p / constant calls for debugging and all kinds of mixed pain .

2.) Why a team on Microsoft will become such a complete (otherwise) cover, and then do process out of the potential value from ProcessWindowStyle, while another team is such a cover that many Made less complete, but all the useful window styles provided?

The VB.Net team has done a lot to reduce the things for the device for the developer Windows, and I have no problem adding the reference to VB DLL and its use is in your C # program.

This is two teams with different focus, it's all and you do not feel bad about using Microsoft.VisualBasic.Interaction.Shell if it solves your problem needed.

You can also use the reflector to see the actual execution and apply code to yourself, you do not want to refer to DLL.

[edit] - The code added after the comment to show that you can add the interaction. Shell and process]

  int pid = interaction Shell ("Notepad .exe", Appwinn Style. General Focus); Process P = Process Gate processIID (PID); P.Exited + = ((O, E) = & Console.WriteLine ("Exit")); P.EnableRaisingEvents = True; Console.ReadLine ();  

Here I use the Shell method to stop the process, handle the process with the padding, and hooking on the events.

[edit - working for cmd.exe]

It's starting to be a bit laughing for my taste, but it works . Change "New Window" with a random GUID or something to make it unique.

  Microsoft.VisualBasic.Interaction.Shell (@ "cmd.exe / c" "cmd.exe / k start a new window" "," AppWinStyle.NormalFocus); Foreach (Process.GetProcessesByName in the process of the procedure ("cmd") {if (process.MainWindowTitle.EndsWith ("new window")) {process.Exited + = ((O, E) => Console.WriteLine ( "Exit" )); Process.EnableRaisingEvents = True; }}  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -