Created
February 16, 2017 09:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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