My plan is to automatically add my youtube music songs to my library. I thought of a workflow that would recognize the ui elements (are only visible if i hover over it) and would click on it, select add to library and do that for every song in a playlist.
I found out, that many functions/activities i need are in connection with Computer Vision. I dont quite understand how to get a list of all those elements i need and click one after another. I can extract ui elements but i dont know how to get all of them and not only the first one… the for each ui element activity sounds interesting but like i said i dont know how to get all elements i need…
Can someone explain to me how to do this? Or is there already a workflow existing for this problem?
Thanks so much already :)) i tried it with find children and it kinda works… for one element tho… i think the problem is, that find children only recognizes the (first) element i clicked on, the other elements are not included in the array… is there a way to include all of them although they are not shown? via css or something like that in ui explorer maybe?
Also, make sure to set the Find Children activity to Descendants and define an output variable:
Now we can just loop through the array and do whatever we want with each item. For demo purposes I just Get Attribute the innertext so we can see that it’s returning what we want. Make sure to change the For Each activity’s TypeArgument to UiPath.Core.UiElement.
A right-click is easy. Just add it inside the For Each, don’t indicate an element, just enter the loop’s variable item as the Input Element of the Click activity:
And voila, now it right-clicks each song in the playlist. Obviously you’ll want to add some steps after the Right-Click.
Note some tweaks that make it not right-click the first song in the list because it’s the currently playing song and can’t be right-clicked, as well as a keyboard Esc to make the context menu disappear.
You are a true hero, thank you soo much^-^ i am also thinking of an if activity that checks if it says “add to library” or “remove from library” because some songs appear in different playlists or some songs cant even be added.
Again i thank you so much, this helps me so much.
The Check App State I added that looks for Add to Playlist could be set to look for Add to Library instead. So if Add to Library is there, do the relevant steps inside the Target Appears branch. If not, just press ESC and continue to the next song.
You don’t need that. I thought the first song was not clickable because it’s already playing, but that’s not right. The idea was to always skip the first song (index 0).
But since it’s just because something is wrong with that song and it can’t be right-clicked, I used the Check App State to see if the context menu appeared. If it doesn’t, skip the song.
The answer to your error, though, is you have to define a variable to put the index from the For Each into:
Easiest way to do that is just to put your cursor into that field and press CTRL+K then give it a name. I used “index” but you can use whatever you want ie SongIdx, SongRow, whatever makes sense to you.