Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Old 12-18-2004, 12:07 AM   #1
rampguy
Triple-A Player
 
Join Date: Oct 2003
Posts: 121
AppleScript and Firefox (getting front URL)

I've been trying to figure out how to get the frontmost URL from Firefox's frontmost window.
If I just do:
tell application "Firefox"
set myFirefox to properties of front window
end tell

then I get:

{«class pObT»:window, «class pTit»:"Mozilla Firefox 1.0 Now Available", «class curl»:"http://www.mozilla.org/products/firefox/start/", index:1, bounds:{705, 44, 1731, 827}, «class pLcn»:{705, 44}, closeable:true, titled:true, modal:false, resizable:false, zoomable:true, zoomed:true, «class pNMo»:true, «class pMMo»:false, floating:false, visible:true}

However, no matter what I do, I can't access this properties data structure...or any of its components.

Any ideas?

I know I can register to receive reports of new FireFox URL openings but for what I am doing that won't work---I just need to be able to query the currently frontmost URL.

Thanks,

Alex
rampguy is offline   Reply With Quote
Old 12-27-2004, 12:57 PM   #2
killerbass
Registered User
 
Join Date: Dec 2004
Posts: 1
Here's what you are looking for...

tell application "firefox" to set theURL to «class curl» of window 1
killerbass is offline   Reply With Quote
Old 02-17-2005, 01:30 PM   #3
kdevine
Registered User
 
Join Date: Feb 2005
Posts: 1
I am trying to use this to bring back some of the other properties of the firefox window and I cannot retrieve the properties (I am getting a conversion error).

I want to be able to extract each property to a variable. Can someone help me with this? Are the properties being returned an array?
kdevine is offline   Reply With Quote
Old 08-26-2007, 02:40 PM   #4
zonke
Registered User
 
Join Date: Aug 2007
Posts: 1
you can convert the properties to list quite easy:

Code:
tell application "Firefox"	
	set myFirefox to properties of front window as list
end tell
of this page gives you

Code:
{window, "The macosxhints Forums - Reply to Topic", "http://forums.macosxhints.com/newreply.php?do=newreply&noquote=1&p=184698", 1, {0, 44, 1440, 895}, {0, 44}, true, true, false, false, true, false, true, false, false, true}
so

Code:
tell application "Firefox"
	set myFirefox to properties of front window as list
	get item 3 of myFirefox
end tell
gives you the URL.
zonke is offline   Reply With Quote
Old 06-18-2009, 01:26 PM   #5
insomnislacker
Registered User
 
Join Date: Jun 2009
Posts: 1
Try this if you use FF 3.0.x

Code:
tell application "Firefox" to activate

tell application "System Events"
	keystroke "l" using {command down} -- Highlight the URL field.
	keystroke "c" using {command down}
end tell

delay 0.5

the clipboard

That should get you the current URL and not require that you have enabled access for assistive devices.
insomnislacker is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:19 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.