Solved

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

Posted on 2003-11-26
9
539 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A lot of new and distinct gadgets are making their appearance every other day. The latest gadget that has wooed the attention of all gadget lovers and non gadget lovers alike is the Smartwatch. This tiny gadget is capable of offering live access to …
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now