Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After working through some example code I implemented a background worker that did the trick. For more info <a href="http://msdn.microsoft.com/en-us/library/cc221403%28v=vs.95%29.aspx#Y114" rel="nofollow">From msdn - How to: Use a Background Worker</a>.</p> <p>I'm trying to find a more reliable way to ensure the F11 command is processed by the application, but for now I've put in a Thread.Sleep before the SendKeys.</p> <p>Please feel free to leave comments or questions.</p> <pre><code>[DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool SetForegroundWindow(IntPtr hWnd); Process p; //Process p is initialized: p = Process.Start(@"&lt;path\application.exe&gt;"); Form2 oForm; private void transition() { BackgroundWorker bw = new BackgroundWorker(); oForm = new Form2(); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); oForm.Show(); if (bw.IsBusy != true) { bw.RunWorkerAsync(); } } private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { oForm.closethis(); } private void bw_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; if ((worker.CancellationPending == true)) { e.Cancel = true; } else { SetForegroundWindow(p.MainWindowHandle); p.WaitForInputIdle(3000); System.Threading.Thread.Sleep(500); SendKeys.SendWait("{F11}"); //Sends the application into full screen mode } } </code></pre> <p>And the code for the form that fades in and out..</p> <pre><code>public partial class Form2 : Form { public Form2() { this.Visible = false; this.Opacity = 0; InitializeComponent(); this.TopMost = true; this.Visible = true; while (this.Opacity &lt; 1) { this.Opacity += .05; Thread.Sleep(5); this.TopMost = true; } } private void closefade() { while (this.Opacity &gt; 0) { this.Opacity -= .05; Thread.Sleep(5); this.TopMost = true; } this.Close(); } delegate void CloseBack(); public void closethis() { if (this.InvokeRequired) { CloseBack b = new CloseBack(closethis); } else closefade(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload