0

So I have an app that analyses the running apps, my code so far

func running() -> [NSRunningApplication]{
    let base = NSWorkspace()
    let apps = base.runningApplications
    return apps
}

for app in running() {
    print(app.localizedName)
    print("isActive: \(app.isActive) | isHidden: \(app.isHidden) | ")

}

I can determine lots of properties properties. However I want to filter apps that have UI kind of like the ones in the Force Quit Applications menu:fca menu

So any tips on how to filter these apps?

user6879072
  • 441
  • 1
  • 7
  • 17

1 Answers1

0

Filter for activationPolicy == .regular

let apps = base.runningApplications.filter {$0.activationPolicy == .regular}

Source: NSApplicationActivationPolicy

vadian
  • 274,689
  • 30
  • 353
  • 361