.net – Controlling other windows from C# app

netshowwindowwindows

I'm writing a C# app that will aggregate control of several applications (WMP, Google Earth, etc.). For apps that I am not writing myself, I am launching as a process, so I have their handles (handle = Process.Start("C:\whatever.exe"); is the code, I believe).

For it to work smoothly, I need to be able to control the minimized/maximized state of each window, including those I launched with Process.Start(). I've seen several methods that claim to do this, usually requiring an import of user32.dll and applying ShowWindow(handle, state).

I ask two questions. Is this the best way to do this? I'm new to .NET/Windows programming (coming from *nix). Further, I haven't been able to get it to work, so are there any quirks that would catch a newbie?

(FYI: VS 2008 on Windows 7 RTM)

Best Answer

You may also want to check out the Windows Accessibility APIs. Their used extensively within Microsoft for automating UI tests.