[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2003-11-26
9
Medium Priority
?
633 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
7 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
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 …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

873 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