Mac OS - get app window to front

时间:2017-10-12 10:19:41

标签: python macos electron pid

I have electron based app. I open url in electron window using

launcher_process = subprocess.Popen(launcher_path + [launcher_url, 'main', runfromsrc])
self.main_window_pid = launcher_process.pid

In js file create window

mainWindow = new BrowserWindow({width: w, height: h, icon: __dirname + '\\abc.ico', resizable:false, title:"ABC"})

This works fine and opens my app url. Now if I change screen to other app like safari. Then from agent app in tray I want to bring electron window in front. Agent app in tray is created from native NSApplication.

I tried

from AppKit import NSRunningApplication, NSApplicationActivateIgnoringOtherApps
            ap = NSRunningApplication.runningApplicationWithProcessIdentifier_(electron_pid)
            ap.activateWithOptions_(NSApplicationActivateIgnoringOtherApps)

This do not work. ap is None.

Is there a way to get hold of electron window through pid and get it in front.

0 个答案:

没有答案