See the question and my original answer on StackOverflow

This is typically a use-case for the UIAutomation technology. Here is a sample C# console app that does this:

dynamic instance = Activator.CreateInstance(Type.GetTypeFromProgID("Photoshop.Application"));

// add a COM reference to "UIAutomationClient"
// uncheck "Embed interop types" in the UIAutomationClient Reference properties (or redeclare the ids manually)
var uia = new UIAutomationClient.CUIAutomation();
var root = uia.GetRootElement();

// find Photoshop window (it's a top level window)
var ps = root.FindFirst(UIAutomationClient.TreeScope.TreeScope_Children,
            uia.CreatePropertyCondition(UIAutomationClient.UIA_PropertyIds.UIA_LocalizedControlTypePropertyId, "window"),
            uia.CreatePropertyCondition(UIAutomationClient.UIA_PropertyIds.UIA_ClassNamePropertyId, "Photoshop")

if (ps != null)
    // this is not to be confused with Win32's SetFocus API
    // it does a lot more

To determine how to search for Photoshop, you can use the Inspect tool from Windows SDK and you will see something like this:

enter image description here

Where the "localized control type" is "window" and the ClassName" is "Photoshop".