Solved

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

Posted on 2003-11-26
9
571 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 125 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
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mac Mini hanging a few minutes after logon 6 94
Shutdown all of many Sierra applications... 4 43
export "on my mac" folders to outlook 2016 2 58
Apps for MACPRO 6 45
The /etc/authorization file in Mac OS X 10.x can be used to control access to the various panes of the System Preferences amongst other things. It’s used by some of us Mac Sys Admin’s to give Standard Users access to System Prefs panes that only adm…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
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 …

734 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