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


Click here to return to the '10.6: Create global hotkeys to control Google Music playback' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Create global hotkeys to control Google Music playback
Authored by: seanstar12 on Mar 27, '12 11:47:43PM
I am not an apple script guru, but I hacked this together to allow me to search and auto-play along with this. The script prompts for a search, then reloads the page (to 'stop the current playing song'), enters in your new search, and starts playing.

activate
(display dialog "Google Music: Search" default answer "")
set searchResult to text returned of result

set the searchResult to replace_chars(searchResult, " ", "%20")

tell application "Google Chrome"
	set allWins to every window
	set allTabs to {}
	repeat with currWin in allWins
		set allTabs to allTabs & every tab of currWin
	end repeat
	repeat with currTab in allTabs
		try
			if (title of currTab) contains "Google Play" then set musicTab to currTab
		end try
	end repeat
	tell musicTab to execute javascript "document.location.reload();"
	delay 2
	set URL of musicTab to "https://play.google.com/music/listen?u=0#" & searchResult & "_sr"
	tell musicTab to execute javascript "SJBpost('playPause');"
end tell

on replace_chars(this_text, search_string, replacement_string)
	set AppleScript's text item delimiters to the search_string
	set the item_list to every text item of this_text
	set AppleScript's text item delimiters to the replacement_string
	set this_text to the item_list as string
	set AppleScript's text item delimiters to ""
	return this_text
end replace_chars


[ Reply to This | # ]