Getting selected URL from mouse click into AppleScript as variable

I’m convinced there’s a simple answer for this, but neither Google nor MS search are turning anything up, so I humbly submit it to the forum gods for your kind consideration.

When building a service in Automator, you can choose to receive selected URLs as an input (pictured below). I have a service that uses this to take a URL and open it in Safari, so I can right click on a URL in any app, launch the service, and open the URL in Safari. So far so good.

What I really want to be able to do is get the URL from the mouse pointer without using Automator. That way I can trigger the “open in Safari” script using Better Touch Tool (or whatever). How do I go about getting my selected URL into my AppleScript? Here’s the code I have:

property theURL : ""
set theURL to URL_i_selected_with_my_mouse
tell application "Safari"
	tell window 1
		set current tab to (make new tab with properties {URL:theURL})
	end tell
end tell

Hi,

this is not possible with vanilla AppleScript.
The Automator service uses Cocoa functions and events

Thanks a lot for the reply. I’ll take a look around. Any idea offhand which functions i would need to call?