chauncey-garrett / scripts-sonos

Applescripts for SONOS
http://chauncey.io/projects/scripts/sonos/
9 stars 2 forks source link

Support all default keyboard shortcuts in Sonos app via GUI scripting #2

Open chauncey-garrett opened 9 years ago

chauncey-garrett commented 9 years ago

Until a better method is worked out, support the default keyboard shortcuts via GUI scripting.

chauncey-garrett commented 9 years ago

screenshot 2014-11-29 14 03 39

chauncey-garrett commented 9 years ago

Trying out UI automation via JXA (Javascript Automation for Mac). I have the following code for the Search shortcut (⌥⌘F):

Sonos = Application('Sonos')
Sonos.activate()

delay(1)

SystemEvents = Application('System Events')
SonosUI = SystemEvents.processes['Sonos']

SystemEvents.keystroke('f', {
        using: 'option down',
        using: 'command down',
    })

For some reason, this doesn't work. Very odd. If I simplify the script to work for Play/Pause (⌘P), it works just fine:

Sonos = Application('Sonos')
Sonos.activate()

delay(1)

SystemEvents = Application('System Events')
SonosUI = SystemEvents.processes['Sonos']

SystemEvents.keystroke('p', {
        using: 'command down',
    })
chauncey-garrett commented 9 years ago

I can get the search working properly with AppleScript. Doesn't seem to be related to Sonos.app.

kevnm67 commented 9 years ago

I spent a little time making a small Mac app to control sonos. I'll post the project in the next day or so.

chauncey-garrett commented 9 years ago

@kevnm67 Sweet! Keep me in the loop.