Solved

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

Posted on 2003-11-26
9
545 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Office365 / office 2016  for MAC 4 49
VMWare Fusion 6 On Mac - Need To Increase Disk Size 17 61
Auto-rotate google map 1 64
Data recovery for MAC 4 44
iCloud Drive was introduced after iOS 8 was launched last year. This drive is Apple’s online storage device that lets users sync their files and access them from all their Apple devices.   There is a lot of data that is not automatically backed up…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 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

22 Experts available now in Live!

Get 1:1 Help Now