1

I'm working on this Alfred Workflow: https://github.com/gustavosaez/Alfred-Workflow-Apple-Music-Playlist

And today I'm looking for a day to "automate" the play music in background or hidden (to avoid open the application and click PLAY).

I found a way to set the mouse click on a screen position (specific on the play button), but it works only if the app is visible and if the resolution of screen is the same of mine.

I search about UI Elements for Music.app and didn't find anything.

The problem is:

  • When Alfred opens the chosen link, Music.app take a few seconds to open and load the playlist selected;
  • After this, space/play command is inactive, so I think to create a script that gets the current page and play the playlist in shuffle mode.

Any idea?

some ideas:

tell application "Music"
    -- tell application "System Events" to tell process "Music" to click at {620, 374}
    play current playlist
end tell

|

tell application "Music"
    -- tell application "System Events" to tell process "Music" to click at {620, 374}
    play {workflowPlaylistName}
end tell

tell application "System Events"
    keystroke "h" using command down
end tell
Saez
  • 11
  • 3

1 Answers1

1

I'm confused why you are trying to use mouse clicks or keystrokes, instead of just using

 tell application "Music"
    play
 end tell

or

tell application "Music"
    play the playlist named "{query}"
end tell

and pass the name of the playlist as query

Marshall
  • 11
  • 1
  • Hi Marshall, I used the click because the "play" option on Music App (after load the playlist) isn't enabled. I tried and didn't work. About your suggestion to play "{ query}" maybe it works, the problem is how script on Alfred will read the information given by own Alfred (when the playlist is selected)? – Saez Mar 09 '22 at 13:08