View Full Version : Active Window Title
Jul 14, 2009, 06:45 AM
hello, i want to get the title of the active application's window...Please help me how can i get that?? :confused:
Thanks in advance.
Jul 14, 2009, 07:47 AM
I would advise you to have a look at NSWindow in the documentation.
(Managing Titles section)
Jul 14, 2009, 05:51 PM
You didn't say what you were using or what the purpose is. It sounds like you might want AppleScript (if the mystery window is not your app)?
Jul 15, 2009, 01:16 AM
i don't find any help in managing titles as i dont know which is the active application.
i can find the active application name with some other information my [[NSWorkspace sharedworkspace] activeapplication]; but i am not able to get the title of this active application's window.
Jul 15, 2009, 01:18 AM
i am not looking for my application if its active, i want it if any other application other than my own application is active i want its window title.
Please help me!
Jul 15, 2009, 02:18 PM
Here's an AppleScript I found (http://stackoverflow.com/questions/480866/get-the-title-of-the-current-active-window-document-in-mac-os-x) that will do the job:
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
tell application frontApp
if the (count of windows) is not 0 then
set window_name to name of front window
You can call AppleScript from Cocoa using NSAppleScript, or you can do an NSTask and call it from the command-line using the osascript command. See this article (http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html) for details. There might be a way to do it directly from Cocoa but I'm guessing AppleScript is going to be your best bet here.
Jul 16, 2009, 04:12 AM
Hey Thanks it worked..Thanx:)
Jul 24, 2009, 03:58 AM
I am facing few problems with this apple script now.
Like when i open firefox, it shows a window "Where is Firefox-bin?"
why is this coming??
I think i need to do this by cocoa.
Please suugest me some way.