public void DisplayExistingUI() { var thisProcess = Process.GetCurrentProcess(); var processes = Process.GetProcessesByName(thisProcess.ProcessName).Where(p => p.Id != thisProcess.Id); foreach (Process runningProcess in processes) { NSRunningApplication app = NSRunningApplication.GetRunningApplication(runningProcess.Id); app.Activate(NSApplicationActivationOptions.ActivateAllWindows); } }
public static bool Activate(int pid, int wait = 5000) { NSRunningApplication app = null; for (; wait > 0; wait -= 100) { if (app == null) { app = NSRunningApplication.GetRunningApplication(pid); } if (app != null && app.FinishedLaunching) { if (app.Activate(NSApplicationActivationOptions.ActivateIgnoringOtherWindows)) { return(true); } } NSThread.SleepFor(0.1); } return(false); }