Applescript Minimise

Reply
Highlighted

Applescript Minimise

Music Fan

Device

Macbook Pro 2019

Operating System

macOS Catalina

 

My Question or Issue

I am writing a script to auto-play a song, but then I want Spotify to minimise - it is maximised because the script "activates" Spotify first.

 

None of the standard minimized commands work:

https://stackoverflow.com/questions/3564160/code-for-minimizing-application-window-in-mac

 

➜ osascript -e 'tell application "Spotify" to set miniaturized of every window to true'
30:70: execution error: Spotify got an error: Can’t make miniaturized of every window into type specifier. (-1700)
➜ osascript -e 'tell application "Spotify" to set minimized of every window to true'
30:67: execution error: Spotify got an error: Can’t make minimized of every window into type specifier. (-1700)

I have managed to get it working with System Events but the command is a little ugly and requires additional accessibility permissions

SUGGESTED POSTS