Search code examples
macoscocoaquartz-graphicsnswindowmacos-carbon

Manipulating a Window in a Mac Application


I have the following code snippet:

 NSNumber* windowNumber = [entry objectForKey:(id)kCGWindowNumber];

 applicationName = [entry objectForKey:(id)kCGWindowOwnerName];

with this I grab the window number and the name from the window server of all Applications running.

What I want to do finally is to create a reference to whatever Window and manipulate its properties, for example if I have the window number of some instance of Safari, I would like to set it back or maximize it or maybe hide it. It is possible to do this ? some idea about how to start?

BTW I found this way of retrieve the "window number" and "application name" in an Apple Code sample Called Son of grab: http://developer.apple.com/library/mac/#samplecode/SonOfGrab/Introduction/Intro.html if someone are curious.


Solution

  • Finally I accomplished this based on the apple sample Son of grab and by using the QUARTZ EVENT TAPS. This is a right way to filter events and manipulate other applications because it serves as a section 508 enabling technology.