fix: don't crash when focusing an app that was closed (closes #19)

This commit is contained in:
Louis Pontoise committed 2019-09-30 11:56:13 +09:00
1 parent 8773b1dceb
commit 6b5e426e05
1 file changed
+4 -2
+4 -2
View File
@@ -26,8 +26,10 @@ class OpenWindow {
}
func focus() {
NSRunningApplication(processIdentifier: ownerPid!)!.activate(options: [.activateIgnoringOtherApps])
AXUIElementPerformAction(target!, kAXRaiseAction as CFString)
if let app = NSRunningApplication(processIdentifier: ownerPid!) {
app.activate(options: [.activateIgnoringOtherApps])
AXUIElementPerformAction(target!, kAXRaiseAction as CFString)
}
}
}