Kyle Oliveira
Kyle Oliveira

Reputation: 197

Get the Focused Window on Mac OS X

I'm want to get the focused window reference in my Cocoa App and I really don't know how. I've read some articles about Accessability API and others about CGWindow but it still not Clear. I got to be able to determine the position of the current focused window, even though it's not from my application (It would be an iTunes Window or a Finder window).

Upvotes: 1

Views: 3419

Answers (2)

pseudosudo
pseudosudo

Reputation: 6590

I realize this doesn't quite answer your question, but if you're willing to settle for the current application instead of the currently focused window then you should use the currentApplication method of NSRunningApplication. More here.

Upvotes: 0

Fatso
Fatso

Reputation: 1318

The first window in [NSApp orderedWindows] should fit your needs.

Upvotes: 1

Related Questions