?
Solved

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

Posted on 2003-11-26
9
Medium Priority
?
599 Views
Last Modified: 2010-04-29
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
0
Comment
Question by:Ozzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:pike480
ID: 9827754
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?
0
 

Author Comment

by:Ozzard
ID: 9830452
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.
0
 
LVL 1

Accepted Solution

by:
allenwatson earned 500 total points
ID: 9838938
What you want is "name of the front window" in AppleScript. But that has to be addressed to the application that owns the window, so you first need to know what application is active. Something like this (on OSX) should work:

 tell application "System Events" to set curapp to name of first process whose frontmost is true

 tell application curapp to set winName to name of the front window

 display dialog "Front window is named /"" & winName & "\""
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 8

Expert Comment

by:pike480
ID: 9839720
why don't you just look at the top command in the terminal?
0
 
LVL 5

Expert Comment

by:Insolence
ID: 9880665
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
0
 
LVL 1

Expert Comment

by:Melandra
ID: 15658250
My apologies; I hadn't realised that this one was still open.
0
 

Author Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
A professional opinion on which Apple product to buy, and a tidbit about the WWDC.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question