How would I programmatically activate i.e move-to-front-and-focus a window on macOS (not belonging to my app) given its Window ID
. My app would run with user granted Accessibility permissions etc.
Surprisingly, none of the functions described on the Quartz Window Services page seem to do that.
Am using Swift currently, but am open to using Objective-C, AppleScript or whatever.
EDIT:
I don't want to bring to front all windows of the parent app - only the specific that matches the window ID.
Edit:
I know that the NSWindow
type is only meant to refer to windows of the current process, but is there no class that represents windows owned by external apps? Like we have NSRunningApplication
to refer to any running app including external ones, I was expecting an API to deal all open windows (assuming the right permissions). Is there some class like NSOpenWindow
or CGWindow
buried somewhere?