Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the title of the current active Window/Document in Mac OS X
    primarykey
    data
    text
    <p>Refering to a previously asked <a href="https://stackoverflow.com/questions/373020/finding-the-current-active-window-in-mac-os-x-using-python" title="question">question</a>, I would like to know how to get the title of the current active document.</p> <p>I tried the script mention in the answers to the question above. This works, but only gives me the name of the application. For example, I am writing this question: When I fire up the script it gives me the name of the application, i.e. "Firefox". This is pretty neat, but does not really help. I would rather like to capture the title of my current active document. See the image. </p> <p><a href="http://img.skitch.com/20090126-nq2egknhjr928d1s74i9xixckf.jpg" rel="nofollow noreferrer">Firefox title http://img.skitch.com/20090126-nq2egknhjr928d1s74i9xixckf.jpg</a></p> <p>I am using Leopard, so no backward compatibility needed. Also I am using Python's Appkit to gain access to the NSWorkspace class, but if you tell me the Objective-C code, I could figure out the translation to Python. <hr> Ok, I've got a solution which is not very satisfing, thats why I don't mark Koen Bok's answer. At least not yet.</p> <pre><code>tell application "System Events" set frontApp to name of first application process whose frontmost is true end tell tell application frontApp if the (count of windows) is not 0 then set window_name to name of front window end if end tell </code></pre> <p>Save as script and invoke it with osascript from the shell.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload