Skip to content

Instantly share code, notes, and snippets.



Created Jul 10, 2019
What would you like to do?
List MacOS MenuBar items
import Foundation
import CoreGraphics
let windowInfos = CGWindowListCopyWindowInfo(CGWindowListOption.optionOnScreenOnly, kCGNullWindowID) as! Array<CFDictionary>
for item in windowInfos {
if let dict = item as? [CFString: AnyObject] {
if ( dict[kCGWindowLayer] as! Int == 25 && dict[kCGWindowOwnerName] as! String != "SystemUIServer" ) {
print("StatusBar Item \(dict)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment