7
4
What is the best way to configure a global keyboard shortcut to open a tab in Chrome on Mac OS X?
Caveats
- It should be as simple as possible, so I don't want to
<alt><tab>
+<cmd><t>
every time. - This must be global, so if I press my shortcut (which happens to be
<cmd><return>
) while I'm in Mail.app, it needs to bring Chrome to the front and open a new tab - It needs to open the new tab page, i.e.
chrome://newtab
, not a website likehttp://www.google.com
- The highest priority is that it opens fast fast fast, the next priority is ease of configuration
Current Solution
Right now I've got Quicksilver.app configured to
execute the following AppleScript (or
osascript
to be precise) whenever I press <cmd><return>
:
#!/usr/bin/osascript
tell application "Google Chrome Canary"
activate
end tell
tell application "System Events"
tell process "Google Chrome Canary"
tell menu bar 1
tell menu bar item "File"
tell menu "File"
click menu item "New Tab"
end tell
end tell
end tell
end tell
end tell
The problem with this is that it can take up to 5 seconds if it has been a
while since I ran it last. I had complied this into a *.app, but that was
slower than making it an executable osascript
. I'm not afraid to try
developing a compiled version of the above script, but I'm a UNIX/web
developer, not OS X, and I'm not familiar with the system.
Place that script in
~/Library/Scripts
and enable the Scripts menu item in AppleScript Editor's preferences. Don't use it for a while, then invoke using that menu. I'm afraid the delay is inherent to AppleScript needing to load up, and this is the "purest" solution I can think of (except invoking the script application directly from Finder) to try to narrow down the causes. – Daniel Beck – 2011-06-01T14:30:10.527