Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 14, 2009, 06:45 AM   #1
ruhi
macrumors member
 
Join Date: Jun 2009
Active Window Title

hello, i want to get the title of the active application's window...Please help me how can i get that??

Thanks in advance.
ruhi is offline   0 Reply With Quote
Old Jul 14, 2009, 07:47 AM   #2
SRossi
macrumors regular
 
Join Date: May 2009
Location: Glasgow, Scotland
I would advise you to have a look at NSWindow in the documentation.

(Managing Titles section)

Stephen
__________________
macMini, 2.0 GHz Core 2 Duo, 1 GB RAM, 120GB hd;
Dell S2209W 21.5" monitor;
iPhone 4GS 16GB;
30 GB iPod video;
SRossi is offline   0 Reply With Quote
Old Jul 14, 2009, 05:51 PM   #3
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
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)?
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Jul 15, 2009, 01:16 AM   #4
ruhi
Thread Starter
macrumors member
 
Join Date: Jun 2009
active window title

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.
ruhi is offline   0 Reply With Quote
Old Jul 15, 2009, 01:18 AM   #5
ruhi
Thread Starter
macrumors member
 
Join Date: Jun 2009
active window title

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!
ruhi is offline   0 Reply With Quote
Old Jul 15, 2009, 02:18 PM   #6
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Here's an AppleScript I found that will do the job:

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
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 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.
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Jul 16, 2009, 04:12 AM   #7
ruhi
Thread Starter
macrumors member
 
Join Date: Jun 2009
Thanks

Hey Thanks it worked..Thanx
ruhi is offline   0 Reply With Quote
Old Jul 24, 2009, 03:58 AM   #8
ruhi
Thread Starter
macrumors member
 
Join Date: Jun 2009
Active window title

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.
Thanks,
Ruhi.
ruhi is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Screen copy active window Barney63 MacBook Pro 3 Mar 14, 2014 12:49 AM
Unexpected Images in Window Title Bars lestye iMac 2 May 6, 2013 07:47 PM
Show Window without activating (keep application below it active) wesleyh Mac Programming 0 Feb 26, 2013 04:08 AM
What causes window to max when scrollwheel on title bar? xgman OS X 10.8 Mountain Lion 3 Sep 21, 2012 07:47 AM
Active Window in Mac OSX saqibjaan Mac Programming 11 Sep 14, 2012 07:12 AM

Forum Jump

All times are GMT -5. The time now is 03:21 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC