Switching between applications like alt+tab?

I have a menu application that launches other unity applications. I’m trying to create a script that automatically “alt+tabs” out of the menu to the started application if the menu is opened while the other application is running. I’ve tried c#'s SwitchToThisWindow, ShowWindow and SetForegroundWindow, but none of them seem to do anything. Any pointers?

Here’s what I’m currently doing:

private static void ChangeFocus(Process pr)
{
    System.IntPtr hWnd;
    hWnd = pr.MainWindowHandle;
    SwitchToThisWindow(hWnd, true);
    ShowWindow(hWnd, 3);
    SetForegroundWindow(hWnd);
}

The function is called when the other process is running and the menu application gets focus (OnApplicationFocus).

Seems that Process.Responding is always false for a unity application. Is this normal?

did you ever find a solution for this?

currently seeing the same result for built application. setforegroundwindow seems to do nothing.