Help with Opening Spotify and start playlist
Moderators: JRL, Dorian (MJT support)
Help with Opening Spotify and start playlist
Hello everyone!
I dont know where in this forum this topic should be posted, so move it if it needs to move!
I am new to Macro Scheduler!(downloaded it yesterday. I am new if I havent used it before, with that, I mean I cant remember if I have used MS before!)
Now over to my question!
What I am , trying to do, is a macro that opens Spotify, clicks on a specific playlist in the left sidebar and plays the first song of the playlist, so now I wonder how to do this after I has been worked with it too many hours yesterday!
Help me!
Bye!
Edited 28th Oct 2020 7:55pm cet:
Finally finished my macro!
I dont know where in this forum this topic should be posted, so move it if it needs to move!
I am new to Macro Scheduler!(downloaded it yesterday. I am new if I havent used it before, with that, I mean I cant remember if I have used MS before!)
Now over to my question!
What I am , trying to do, is a macro that opens Spotify, clicks on a specific playlist in the left sidebar and plays the first song of the playlist, so now I wonder how to do this after I has been worked with it too many hours yesterday!
Help me!
Bye!
Edited 28th Oct 2020 7:55pm cet:
Finally finished my macro!
Last edited by myran1178 on Wed Oct 28, 2020 6:55 pm, edited 1 time in total.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
Hi Ryan,
I downloaded Spotify so I could see what your challenges may be, and what works and what doesn't.
This is how I built the script at the bottom of this reply :
First I used Run to start Spotify.
Then we wait for the Spotify window to open with WaitWindowOpen, and Wait for a few seconds for the contents to load. There are more intelligent ways of waiting, but we can leave those for another day (see Image Recognition or UIAccessibleList - advanced)
Now we can use the Find Object Wizard to generate the button clicks.
I found that simply clicking the playlist was unsuccessful unless I just ran the UIClick lines straight from the editor with Spotify already open, and that we needed to use UIFocus first, wait for a moment, then click with UIClick.
Thus we end up with :
I downloaded Spotify so I could see what your challenges may be, and what works and what doesn't.
This is how I built the script at the bottom of this reply :
First I used Run to start Spotify.
Then we wait for the Spotify window to open with WaitWindowOpen, and Wait for a few seconds for the contents to load. There are more intelligent ways of waiting, but we can leave those for another day (see Image Recognition or UIAccessibleList - advanced)
Now we can use the Find Object Wizard to generate the button clicks.
I found that simply clicking the playlist was unsuccessful unless I just ran the UIClick lines straight from the editor with Spotify already open, and that we needed to use UIFocus first, wait for a moment, then click with UIClick.
Thus we end up with :
Code: Select all
//Run Spotify (you'll need to change the path)
run>C:\Users\xb360\AppData\Roaming\Spotify\Spotify.exe
//Wait for spotify to open and wait for contents to load
WaitWindowOpen>Spotify Free
Wait>10
//Focus your playlist (edit this)
UIFocus>{"Spotify Free"},{"PlayList Test"}
Wait>1
//Click on the playlist (edit this) and wait
UIClick>{"Spotify Free"},{"PlayList Test"}
Wait>5
//Click play
UIClick>{"Spotify Free"},{"PAUSE"}
Re: Help with Opening Spotify and start playlist
I want it to work even if the bottom player is empty!
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
Not being a Spotify user I really don't know what the bottom player refers to. Hopefully you're able to use my suggestions above as a starting point by familiarising yourself with the wizards and commands I outlined. They're merely suggestions to get you started.
Re:Re:Re: Help with Opening Spotify and start playlist
I was talking about this when I said Bottom player!
https://imgur.com/a/shEQjxv
Cant remember the real name of it so I called it the most logical name(the most logical name is Bottom player cause it is located to the bottom!)
https://imgur.com/a/shEQjxv
Cant remember the real name of it so I called it the most logical name(the most logical name is Bottom player cause it is located to the bottom!)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
Try the Find Object Wizard as mentioned above, and if that fails use Image Recognition.
Re: Help with Opening Spotify and start playlist
I like everything of your code except the play section.
I tried to say that I want my macro to play the first song of playlist doesnt matter if bottom player is filled with something else i listened to recently or bottom player is empty. I think your method requires the bottom player
to be not empty cause it plays the most recent song, not the first song of playlist.
I tried to say that I want my macro to play the first song of playlist doesnt matter if bottom player is filled with something else i listened to recently or bottom player is empty. I think your method requires the bottom player
to be not empty cause it plays the most recent song, not the first song of playlist.
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
Once you've clicked the playlist you should be able to use CTRL-Left Arrow to navigate up the list.
You can then press play. Use the Find Object Wizard I mentioned above to generate the code (or use Image Recognition)
Code: Select all
SetFocus>Spotify Free*
press ctrl
press left *20
release ctrl
Code: Select all
UIClick>{"Spotify Free"},{"Play"}
Re: Help with Opening Spotify and start playlist
How to create a message window that displays the name/title of active window?
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
Check out GetActiveWindow and Messagemodal.
Re: Help with Opening Spotify and start playlist
I know but I wonder how to use the active window variable in the message!
Re: Help with Opening Spotify and start playlist
Found it out now!
Re: Help with Opening Spotify and start playlist
Help me with the lines that says "needs help":
SCREENSHOT SHOWING SnapShotFile>%BMP_DIR%snapshot_32.png AND SnapShotFile>%BMP_DIR%snapshot_33.png:
https://imgur.com/a/j9m5QNe
Code: Select all
//NEEDS HELP WITH CREATING SHORTER AND FASTER MACRO
//đź —SAVING PREVIOUS ACTIVE WINDOW LINES 2-5 DONEđź —
GetActiveWindow>strTitle,nXPos,nYPos,,
Let>FörraFönstret=%strTitle%
GetWindowSize>%FörraFönstret%,nWidth,nHeight
GetWindowPos>%FörraFönstret%,nXPos,nYPos
//đź —OPENING SPOTIFY AND START THE FIRST SONG OF PLAYLIST LINES7-21 DONEđź —
run>Spotify.exe
WaitWindowOpen>Spotify Premium
Wait>10
UIFocus>{"Spotify Premium"},{"Niall Horan – Flicker (Deluxe)"}
Wait>1
UIClick>{"Spotify Premium"},{"Niall Horan – Flicker (Deluxe)"}
Wait>5
UIFocus>{"Spotify Premium"},{"Niall Horan – Flicker (Deluxe)"}
Wait>1
UIClick>{"Spotify Premium"},{"On The Loose"}
SetFocus>Spotify*
UIClick>{"Spotify Premium"},{"SPELA UPP"}
press ctrl
press left *20
release ctrl
//đź —ASKING ME IF I WANT OR NOT WANT CONTINUE WHAT I DID BEFORE THIS STARTED. IF YES, RE ACTIVATE PREVIOUS ACTIVE WINDOW.
//DONE LINES 24-29đź —
Ask>Vill du fortsätta med det du gjorde innan Spotify?,strResponse
If>%strResponse% = "Yes"
WindowAction>2,Niall Horan - On The Loose
SetFocus>%FörraFönstret%
MoveWindow>%FörraFönstret%,%nXPos%,%nYPos%
ResizeWindow>%FörraFönstret%,%nWidth%,%nHeight%
//đź —IF I CLICKED NO, REACTIVATE SPOTIFY AGAIN AND MAXIMIZE SPOTIFY. NEEDS HELP WITH THIS LINES 31-54đź —
Else
// C:\Users\Miranda\AppData\Local\Temp\msrFBE6.scp
// Recorded on lördag, oktober 24, 2020, at 05:12 PM
//Recorded Events
Let>WW_TIMEOUT=5
CapsOn
MouseMove>485,749
Wait>1.613
//Clicking on:
//SnapShotFile>%BMP_DIR%snapshot_32.png
Wait>1.531
LClick
Wait>0.282
//Activating Window:
//SnapShotFile>%BMP_DIR%snapshot_33.png
WaitWindowOpen>Spotify Premium
MoveWindow>Spotify Premium,486,112
ResizeWindow>Spotify Premium,800,600
Wait>2.937
SetFocus>Niall Horan - On The Loose
MouseMoveRel>1219,127
Wait>8.959
LClick
https://imgur.com/a/j9m5QNe
- Dorian (MJT support)
- Automation Wizard
- Posts: 1414
- Joined: Sun Nov 03, 2002 3:19 am
Re: Help with Opening Spotify and start playlist
If you mean making it faster, simply trim those recorded Waits down near the bottom.
Also this needs editing :
Also this needs editing :
Code: Select all
If>%strResponse%=YES
Re: Help with Opening Spotify and start playlist
Help me also with the part under the last code comment