Behrang Saeedzadeh
Behrang Saeedzadeh

Reputation: 47913

Is there a Swift macOS/Cocoa API that can detect when the current foreground app changes?

Is there a Swift API that can notify when the current active/foreground window changes and provide information about the title of the foreground window, the application name, etc?

Something similar to this, but not only monitoring the current application but all running apps across the system.

Upvotes: 2

Views: 864

Answers (1)

vadian
vadian

Reputation: 285069

There is the didActivateApplicationNotification in NSWorkspace.

A notification that the workspace posts when the Finder is about to activate an app.

However NSRunningApplication which is the object of the posted notification doesn't provide information about the active window.

Upvotes: 2

Related Questions