Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcut #51

Open
wmertens opened this issue Feb 20, 2019 · 0 comments
Open

Keyboard shortcut #51

wmertens opened this issue Feb 20, 2019 · 0 comments

Comments

@wmertens
Copy link

It would be great if there was a shortcut that creates a new Play Music panel (without tabs etc) or switches to it if it exists. That way,

I have some code at https://github.com/wmertens/global-chrome-tab for opening tabs with a global shortcut, but right now I'm using this applescript:

tell application "Google Chrome"
	if frontmost then
		set w to window 1
		if visible of w is true and (URL of active tab of w) contains "music/listen" then
			-- Chrome uses minimized instead of miniaturized
			set minimized of w to true
			return
		end if
	end if
	activate
	set i to 0
	repeat with w in (windows)
		set i to i + 1
		set j to 0
		repeat with t in (tabs of w)
			set j to j + 1
			if URL of t contains "music/listen" then
				set (active tab index of w) to j
				set index of w to 1
				tell application "System Events" to tell process "Google Chrome"
					perform action "AXRaise" of window 1 -- `set index` doesn't always raise the window
					-- keystroke "f" using {option down, command down}
				end tell
				return
			end if
		end repeat
	end repeat
	activate
	set w to make new window
	-- set URL of active tab of w to "https://play.google.com/music/listen"
	
	-- wait for the tab to load so js can run
	delay 1
	-- this needs developer access - alternatively use the "set URL" line above
	execute of active tab of w javascript "window.open('https://play.google.com/music/listen','window','toolbar=no, menubar=no, location=no, resizable=yes noopener=yes')"
	close w
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant