0

I have an WPF application. For fast launching the keyboard in my app, I want to start Keyboard process and application in the same time. For this I added to MainViewModel() my function StartKeyboardProcess() with next description:

string keyboardPath = ConfigurationManager.AppSettings["KeyboardPath"]; 

ProcessStartInfo startInf = new ProcessStartInfo();
startInf.FileName = keyboardPath;
//startInf.WindowStyle = ProcessWindowStyle.Hidden;
startInf.UseShellExecute = false;
startInf.CreateNoWindow = false;
startInf.RedirectStandardOutput = true;
startInf.Arguments = Model.AppCulture.ToString() + " " + Model.AccountWithPhoneAbility.ToString(); 

KeyboardProcess = Process.Start(startInf);
KeyboardProcess.EnableRaisingEvents = true;
KeyboardProcess.Exited += keyboardProcess_Exited;
KeyboardProcess.OutputDataReceived += KeyboardProcess_OutputDataReceived;
KeyboardProcess.BeginOutputReadLine();


//It's my debug file
<add key="KeyboardPath" value="D:\Kickle\LyncBox-Dev\LyncBox.Tool.KickleKeyBoard\bin\Release\LyncBox.Tool.KickleKeyBoard.exe" xdt:Transform="Insert"/>

I want to hide the window of KeyboardProcess, but I didn't manange to do this. I tried all the way like CreateNoWindow, ProcessWindowStyle.Hidden, but it doesn't work for me. Help me! Thanks.

  • CreateNoWindow only applies to console mode apps. ProcessWindowStyle.Hidden is routinely ignored by GUI apps, it is by WPF, it traps the user. The user loses all control over the app since there isn't any way for him to activate the window. Only terminating the process with Task Manager is possible. You'll have to write your WPF app to accommodate this, a command line argument is a simple way to do this. Do keep in mind that the OutputDataReceived event will never fire and you'll only ever get the Exited event when the user uses Task Manager. You'd better think this through a bit. – Hans Passant Apr 12 '16 at 09:10
  • Think this has been answered before. Try this link: http://stackoverflow.com/a/14765016/616304 – Stephen Wilson Apr 12 '16 at 09:10
  • Thanks, but for me this link doesn't work. – Павел Лягушин Apr 12 '16 at 09:29

0 Answers0