Created
April 20, 2016 18:52
-
-
Save stefanocoding/9168249a7eaaf5b228e532525b9c6cb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
let workspace = NSWorkspace.sharedWorkspace() | |
let activeApps = workspace.runningApplications | |
for app in activeApps { | |
if app.active { | |
let listOptions = CGWindowListOption(arrayLiteral: CGWindowListOption.OptionOnScreenOnly) | |
let windowList : NSArray = CGWindowListCopyWindowInfo(listOptions, 0)! | |
for window in windowList { | |
if (window["kCGWindowOwnerName"] as! String) == app.localizedName { | |
let topWindow = window as! NSDictionary | |
break | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment