You need to know the window class and/or title and then can use FindWindow to get a window handle for the window:
[DllImport("coredll.dll", EntryPoint="FindWindowW", SetLastError=true)]
private static extern IntPtr FindWindowCE(string lpClassName, string lpWindowName);
Using the window handle you can change the window back to normal display using SetWindowPos:
[DllImport("user32.dll", SetLastError=true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
In example, if the window has a class name of "App 3"
...
IntPtr handle;
try
{
// Find the handle to the window with class name x
handle = FindWindowCE("App 3", null);
// If the handle is found then show the window
if (handle != IntPtr.Zero)
{
// show the window
SetWindowPos(handle, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
}
}
catch
{
MessageBox.Show("Could not find window.");
}
To find the window's class and title, start the CE remote tool "CE Spy" (part of VS installation) when app 3 is started. Then browse thru the window list and look the app 3 window. Double click the entry in the list and you will get the class name and title of app 3.
Instead of the extra SetWindowPos you can also use the simple ShowWindow API:
[DllImport("coredll.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);
enum ShowWindowCommands
{
Hide = 0,
Normal = 1,
ShowMinimized = 2,
Maximize = 3, // is this the right value?
ShowMaximized = 3,
ShowNoActivate = 4,
Show = 5,
Minimize = 6,
ShowMinNoActive = 7,
ShowNA = 8,
Restore = 9,
ShowDefault = 10,
ForceMinimize = 11
}
...
IntPtr handle;
try
{
// Find the handle to the window with class name x
handle = FindWindowCE("App 3", null);
// If the handle is found then show the window
if (handle != IntPtr.Zero)
{
// show the window
ShowWindow(handle, ShowWindowCommands.Normal);
}
}
catch
{
MessageBox.Show("Could not find window.");
}
For details about pinvoke of FindWindow and SetWindowPos see pinvoke.net and MSDN. Best book about Win32 programming is Charles Petzold's Programming Windows.
When you started the process you need the OS give some time to settle the app (let's say 1-3 seconds), before you change the window.