Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

AppleScript to get Google search URL Apps
In Safari 6, with the new combined URL and search field, if you type search terms into the field, then press return, you'll get a Google page with the results, but you won't get a search URL in the address field. Some people want to save searches at times. Macworld's Dan Frakes tweeted an AppleScript which does just that and Many Tricks developer Peter Maurer improved on it. Run the script and it will get the URL for the frontmost tab then send it to the clipboard, from which you can paste it where you want.
tell application "Safari"
	set the clipboard to URL of current tab of window 1 as string
end tell
As Dan Frakes later pointed out on Twitter, you can also drag the favicon to a finder window. You can double-click the resulting file to redo the search, or you can press the Spacebar to Quick Look it and see a live search with clickable links. For a search, the favicon is the magnifying glass icon at the left of the search field.

So, how many other ways can you find to save a Google search URL?

Update: Jordan Kay posted an even shorter version on Twitter:
 tell application "Safari" to set the clipboard to URL of current tab of window 1 as string
    •    
  • Currently 2.63 / 5
  You rated: 3 / 5 (8 votes cast)
 
[3,182 views]  

AppleScript to get Google search URL | 2 comments | Create New Account
Click here to return to the 'AppleScript to get Google search URL' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
AppleScript to get Google search URL
Authored by: Esquare on Aug 02, '12 08:00:41AM

You can also simply drag the magnifying glass in the search bar to wherever you want it... It automatically changes into the full search string.



[ Reply to This | # ]
AppleScript to get Google search URL
Authored by: Lri on Aug 03, '12 06:07:17AM

tell app "Safari" to set the clipboard to (get URL of document 1) would be even shorter.

The URL is already text / string / Unicode text, but this is one of those cases where AppleScript doesn't do the implicit get.



[ Reply to This | # ]