Question

Is there anything similar to GetForegroundWindow on Mac OS X?

I've two apps one windowed (NSDocument based) and one command line I want to show an NSOpenPanel from command line tool and would like to make it model for the NSDocument based app but don't have the windowref for it?

Was it helpful?

Solution

There are a few problems with what you want.

First of all, applications on the Mac do not have window references. An application may have any number of windows. Second, access to other processes' windows is limited in Mac OS X. There are a few APIs for accessing them in different ways. At any rate, having a reference to another app's window will not allow you to throw up modal dialogs for that application.

What you want is to have the command line app communicate with the foreground app to tell it to show the open panel. You could either establish your own communications protocol (e.g. through Distributed Objects) or you could use Apple Events/AppleScript to communicate back and forth.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top