Skip to content

Instantly share code, notes, and snippets.

@nbogie
Created February 16, 2017 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbogie/da77865c7cf66c26236edd723891bcfe to your computer and use it in GitHub Desktop.
Save nbogie/da77865c7cf66c26236edd723891bcfe to your computer and use it in GitHub Desktop.
simple applescript for midipipe, to allow MIDI control of amazon music player in Chrome
on isMidiButtonPressed(msg, bNumber)
return ((item 1 of msg = 191) and (item 2 of msg = bNumber) and (item 3 of msg > 0))
end isMidiButtonPressed
on jsClick(theTab, sel)
tell application "Google Chrome"
execute theTab javascript ("document.querySelector('" & sel & "').click()")
end tell
end jsClick
on runme(message)
tell application "Google Chrome"
repeat with t in tabs of windows
tell t
if URL starts with "https://music.amazon.co.uk/" then
if (my isMidiButtonPressed(message, 117)) then
my jsClick(it, ".playButton")
end if
if (my isMidiButtonPressed(message, 115)) then
my jsClick(it, ".nextButton")
end if
if (my isMidiButtonPressed(message, 114)) then
my jsClick(it, ".previousButton")
end if
end if
end tell
end repeat
end tell
end runme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment