I have been using this macro for years, even when I used QuicKeys but it is a bit slow and takes about 3 seconds to open the window on a Mac Pro. Not sure what makes it so slow to open the search box.
------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2017/03/28 00:30
# dMod: 2017/03/28 00:39
# Appl: Google Chrome
# Task: YouTube Search with Google Chrome
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Google_Chrome, @YouTube, @Search
------------------------------------------------------------------------------
set frontApp to path to frontmost application as text
tell application frontApp
set mySearchStr to text returned of (display dialog "Enter YouTube Video Search" default answer "" buttons {"Cancel", "Search"} default button "Search")
end tell
set mySearchURL to "http://www.youtube.com/results?search_query=" & mySearchStr
tell application "Google Chrome"
activate
if (count of (get windows)) = 0 then make new window
tell front window
set activeTabURL to URL of active tab
if activeTabURL = "chrome://newtab/" then -- new tab URL might need tweaking for your setup.
set URL of active tab to mySearchURL
else
make new tab at end of tabs with properties {URL:mySearchURL}
end if
end tell
end tell
------------------------------------------------------------------------------
Thank you Michael and Chris, very helpful to see both and see how they compare and to do the same things both ways. The native Keyboard Maestro macro seems a few milliseconds shorter probably just because of the fade for the dialog is not there. Nice to be able to save the AppleScript as an application though.
Because I can double click on it and run it without having to use another application to launch or run it. Just nice to have something like that sometimes that I can stick in my dock for temporary use. I know how to get back into it and edit if I need to which is helpful. AppleScripts like this that I use all the time live in Keyboard Maestro as an AppleScript and don't run as an app. Thanks for the help and post.