Apps Mac News

I’ve been using John Gruber’s suggestions from Going Flash-Free on Mac OS X, and How to Cheat When You Need It to avoid installing Adobe Flash by using Google Chrome (which includes its own version of Flash) whenever I run into a page that has Flash I want to see.
To make this easier, John suggested turning on the “Develop menu” in Safari’s “Advanced” preferences, which includes a sub-menu to “Open Page With” and a sub-sub-menu that shows all of your installed browsers. John suggested using System Preferences to create a keyboard shortcut for “Google Chrome” or “Google Chrome.app” depending on which one you saw in the menu.
Unfortunately, this failed for me quite often. Every time I launched Safari, the keyboard shortcut would not work until I had opened that menu manually using the mouse. I hate using the mouse. After opening the menu, the keyboard shortcut would work until I quit Safari again. That was mildly annoying, but things recently took a turn for the worse.
Here’s what the menu looks like for me now:
Notice that the browser listings now include version numbers. This means that a keyboard shortcut would have to include the version number, which means it would break whenever the browser is updated.
I asked a few folks, and it appears this changed in Safari 5.0.4. I haven’t been able to find a way to revert to the old behavior, so I started looking for another way.

Enter AppleScript

What I needed was a way to open the current Safari page to Google Chrome. After my own attempts at cobbling together an AppleScript solution failed, John Welch was kind enough to provide the the answer via Twitter:
property theURL : ""
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
tell application "Google Chrome"
set URL of active tab of window 1 to theURL
activate
end tell
(I added the “activate” line to make Google Chrome active, which is what I wanted.)
You can download the .scpt file here or copy the above code into AppleScript Editor.app.
I saved the script as an AppleScript file in~/Library/Scripts/Applications/Safari/Open-Safari-URL-in-Chrome.scpt and then used FastScripts to assign a keyboard shortcut (F2, but you can choose anything you want) to the script.
FastScripts is a great program that runs in your menu bar and gives you easy access to AppleScripts, either with the mouse or by letting you assign keyboard shortcuts to them. You can assign up to 10 keyboard shortcuts for free. If you need more than that, a license is $15. It even makes it easy to put certain scripts where they will only be seen by certain applications.
It may be possible to do something similar via ApptivateLaunchBarAlfredQuicksilver or your favorite launcher. If someone comes up with a workable solution for one of them, please let us know in the comments. For me, FastScripts was the easiest and best tool in my toolbox.
What we really need is for someone to write a Safari extension, like ClickToFlash, that will send the current page to Chrome. Free name suggestion: “ClickToChrome.” Until then, this works even better than the original solution, as the keyboard shortcut now works much more reliably.

Troubleshooting

A few times I have seen this error:
Error Number:Google Chrome got an error: Can’t get window 1. Invalid index.
-1719
But it seems to go away if I restart Chrome and/or Safari. I cobbled together this alternative based on a post at Stackoverflow.com:
set backupClipboard to the clipboard

tell application "System Events"
keystroke "lc" using command down
end tell

delay 0.2 -- to make sure keystroke will hit cmd+l & cmd+c

tell application "Google Chrome"
open location (the clipboard)
activate
end tell

set the clipboard to backupClipboard

It seems less elegant and more “hacky” (it is simulating keystrokes to copy the URL from the address bar to the clipboard and then pastes it into Chrome), but if you want to use this instead you can download it here.