DEV Community

loading...

Discussion on: Automating a Mac using AppleScript

Collapse
rikeshmm profile image
Rikesh Makwana

Indeed an interesting read, I was trying to play around with Spotify by writing a script that could notify the user about the next song by skiping the current track using the next track function but it did not update the current track field. It would be fun to know how would you approach this 😁

Collapse
lberge17 profile image
Laura Berge Author

I'm glad you enjoyed reading! I think I'd have to see your code to understand the problem better. However, from videos and tutorials I've watched, it seems AppleScript is sometimes harder to predict what the outcome actually will be which makes debugging interesting. I know a lot of code requires added delays in order for the program to execute all the commands in the sequence we expect.

Collapse
rikeshmm profile image
Rikesh Makwana • Edited

Using delay did fix the problem, I couldn't figure what the issue was all this while without this post! 😂😁
Here is the working code snippet!

tell application "Spotify"
    set track1 to name of current track
    next track
    delay 0.5
    set track2 to name of current track
    get track1 & track2
end tell
Thread Thread
lberge17 profile image
Laura Berge Author

Awesome! I'm glad delay fixed it.