chauncey-garrett / scripts-sonos

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

Play-Pause minimizes sonos #1

Open kevnm67 opened 9 years ago

kevnm67 commented 9 years ago

Running the play-pause script minimizes the sonos window... Here is a solution I just came up with:

tell application "System Events"

    tell process "Sonos"

        set frontmost to true

        keystroke "p" using command down

    end tell

end tell
chauncey-garrett commented 9 years ago

Running the play-pause script minimizes the sonos window...

That's odd. The original script works for me. Are you using the latest and greatest? (i.e., OS X 10.1.1 and Sonos v5.1.1) Also, can you confirm that you have the Script Editor enabled under Accessibility?

2014-11-29 at 13 44

Your solution does indeed work. What I would like to avoid, however, is having to activate the Sonos application. In my experience, this approach works most of the time but breaks often enough to be a hassle.

While troubleshooting, I did notice that the original script doesn't work while Sonos is in fullscreen mode.

Finally, I'm glad you pointed out the keyboard shortcuts. I never knew they existed! I'll open a new issue (#2) to add them all.

2014-11-29 at 13 53

kevnm67 commented 9 years ago

I do have scripts enabled and everything is up to date. When I ran the scripts it minimized the sonos window.

Sure, completely understand about shortcuts. It was the only solution I came up with yesterday because I didn't see the button titles listed when using accessibility inspector.

chauncey-garrett commented 9 years ago

I'm not sure what the discrepancy is between our setups. I think though that since your AppleScript works for both of us and in the Full Screen mode that it is currently the better choice.

I'll update Play/Pause when I add the keyboard shortcuts as AppleScripts but before I do that, did you have any issue with the other scripts currently in the repo?

kevnm67 commented 9 years ago

Cool. I haven't checked the other sono's scripts. I'll check them out and let you know. I tried to fork your hazel workflows but didn't see any... Ive recently been making scripts to organize and automate every day tasks. I'm happy to contribute what I can.

kevnm67 commented 9 years ago

Ok, so im not sure why this keeps happening but the mute script also minimizes sonos. The volume up and down works great, though. The code below works for me. It may be because I'm using better snap tool with custom actions for the red, yellow and green buttons of windows?

-- Mute

tell application "System Events"
      tell process "Sonos"
        click button 4 of window 1
      end tell
  end tell

--Button #'s and corresponding actions: -- 4 - mute -- 5 - play-pause -- 6 - previous track -- 7 - next track -- 8 - search -- 9 - repeat toggle -- 10 - toggle random --11 - crossfade -- 12 - music EQ

chauncey-garrett commented 9 years ago

I've had that itch as well. If you haven't tried it out, give Keyboard Maestro a go. It'll change the way you work.

I have a lot of scripts, macros, snippets, dotfiles, etc. that I need to share to GitHub. Perhaps I'll have time to do so over Christmas. If you want, go to those repos and click the star and watch buttons. You'll be updated whenever I get around to posting everything. Also, when I do I'll post something on my site as well chauncey.io.

For the new script, what happens when you disable BetterSnapTool?

chauncey-garrett commented 9 years ago

@kevnm67 any luck with disabling BetterSnapTool?

kevnm67 commented 9 years ago

No difference when I disable it

chauncey-garrett commented 9 years ago

Not sure what is causing the issue...

Checkout #2. I've posted two scripts using both AppleScript and JXA. Let me know how they work for you, if you don't mind.

kevnm67 commented 9 years ago

I just tried the toggle mini controller, which works

kevnm67 commented 9 years ago

Tried the search javascript and the search field isnt activating. The console logged "Undefined".

chauncey-garrett commented 9 years ago

Good. How bout https://github.com/chauncey-garrett/scripts-sonos/blob/master/search-jxa.scpt? That's the one I had trouble with in JXA but not AppleScript.

chauncey-garrett commented 9 years ago

Same problem I had. The AppleScript version works however. JXA is new. AFAICT, this is a bug between JXA and Sonos. I'd like to make the library in JXA since it's new but it appears from other sources on the internets that JXA is still a work in progress. I think since the AppleScripts work that it'd be best to continue on with them for now.

If you want, using https://github.com/chauncey-garrett/scripts-sonos/blob/master/search-applescript.scpt as a template, feel free to make whatever shortcuts you want from #2 and send me a pull request and I'll add them in. Just let me know if you're going to do so so that we're not working on the same thing.

Otherwise, I'll add them in over the next week or two.

chauncey-garrett commented 9 years ago

Also, if you make commits be sure to look at Readme.md#Installation since I added instruction on using a filter driver.

kevnm67 commented 9 years ago

Ok cool. I updated the config file. I dont know much about JXA yet. I tried changing your script a little but im still getting an error One weird one: "error: no error".... Thanks console, you clarified everything New one I had to share: Error -2700: Script too silly to execute.