Link to home
Start Free TrialLog in
Avatar of Ozzard
Ozzard

asked on

How to obtain the title of the active window on OS-X

I'm trying to fid out whether it's possible to obtain the title of the active window by any means in OS-X.  I'm aware of OSAXen that can tell you the active application; what I'm looking for is the window title of the single active window, no matter what the application is.

Thanks in advance,

- Peter
Avatar of pike480
pike480

try the programming area?

look in the applescript suppor areas?

try <http://www.scriptbuilders.net/>

you can select a window by window name, but I'm not sure you can ask a window for its name. But I'm not a programmer, either. How would you know what window to ask for?
Avatar of Ozzard

ASKER

Thanks for your comment, and for the Scriptbuilders link - I do like the site.  Certainly Applescript looks like the most likely way of interfacing to this information, possibly via an OSAX - the other trick would be to try to do something with the accessibility systems, but I'm not sure where I'd go for information on hooking into them either!

The snag is that I *don't* know what window I'm looking for.  I'm trying to monitor the system to see what's active at any time.
ASKER CERTIFIED SOLUTION
Avatar of allenwatson
allenwatson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
why don't you just look at the top command in the terminal?
Hehe... pike, top shows running processes, it has nothing to do with the front window name, or the front-most program.  =)   Allenwatson's solution looks like it, or a variant of it should work, but that's in Applescript.  I wonder how to do this in C/C++.  =P

 - Insolence
My apologies; I hadn't realised that this one was still open.
Avatar of Ozzard

ASKER

... or, indeed, whether I was logged in from work or home.  Thanks for the pointer, Allen; I did get this working with your input.