4

I'm helping a visually impaired friend learn how to use her Mac. She's using the built-in screen magnifier, which is working great. She likes to access websites (mainly TV streaming services) via links on her desktop, which I'm able to create by hand. However the standard method for creating these (dragging a URL from the location bar in Safari to the desktop) isn't ideal for a visually impaired user.

I was thinking, therefore, that maybe I could write an AppleScript which could create the weblink on the desktop. I'd envisage this script being run from Safari when the user hits a specific keystroke. I've got no experience of writing AppleScript, however. Is it the best approach for what I'm trying to do? How should I go about getting started?

0

1 Answer 1

3

This script will do what you asked. It grabs the URL and the Name of the current Safari tab and creates a weblink file on the desktop. It uses the page's name to name the file. If you want help parsing a better option for the file name, just ask.

try -- will just silently quit if front window is not valid
tell application "Safari"
    set theURL to URL of current tab of window 1
    set theName to name of current tab of window 1
end tell

tell application "Finder"
    make new internet location file at desktop to ¬
        theURL with properties {name:theName}
end tell
end try
4
  • Great answer. I would maybe suggest making the script more robust seeing that this is going to be used by a visually impaired user. The script fails for example when no windows/tabs are open or when a tab is open but it is blank. Additionally, there is the case where there is a valid tab with URL but the preferences window (or any other secondary window) is at the front. In that case, window 1 refers to that window which does not have a URL. This might never come up but you never know.
    – Arthur
    Commented Sep 30, 2015 at 18:20
  • You're right, Arthur. I shouldn't assume that Jim knows how to add try blocks as needed. Especially since this is a such a dear sweet request. I think in this use-case, a simple try block around the whole thing makes the most sense, to just silently fail if Preferences is open or there's nothing loaded into the current web tab... both contexts where initiating the script would've been a mistake in the first place.
    – jweaks
    Commented Sep 30, 2015 at 18:28
  • Also, to the original poster, it occurs to me to make sure you know that when you add links to the Bookmark bar, then you can access the first nine of them with with Command+Option+1, 2, 3, etc.
    – jweaks
    Commented Oct 2, 2015 at 0:58
  • Thanks! I've finally got round to trying this, and it works really well. I think I'm going to assign the script to a keyboard shortcut the next time I see my friend :)
    – Jim
    Commented Oct 20, 2015 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .