Examples:
Current Web Page, Copy to Clipboard
tell application "Safari"
if (count windows) > 1 then
set browserWindow to (first window whose name is not
"Downloads")
else
set browserWindow to window 1
end if
set theURL to URL of current tab of browserWindow
end tell
set the clipboard to theURL
For Camino:
tell application "Camino" to set theURL to URL of current tab of front
browser window
set the clipboard to theURL
Current Web page, Paste:
For Safari:
tell application "System Events"
set {name:theApp, bundle identifier:theIdentifier} to (get 1st
application process whose frontmost is true)
end tell
tell application "Safari"
if (count windows) > 1 then
set browserWindow to (first window whose name is not
"Downloads")
else
set browserWindow to window 1
end if
set theURL to URL of current tab of browserWindow
end tell
tell application "System Events"
tell process theApp
delay 0.2
keystroke theURL
end tell
end tell
If you don't want to use UI scripting for pasting the URL, then a
"service" can be created using ThisService and a shortcut can be
assigned with System Preferences>>Keyboard and Mouse. Here is the
script that you need to use with ThisService:
on process()
tell application "Safari"
if (count windows) > 1 then
set browserWindow to (first window whose name is not
"Downloads")
else
set browserWindow to window 1
end if
set theURL to URL of current tab of browserWindow
end tell
return theURL
end process