Friday, December 13, 2024

itunes – AppleScript (Music.app) error: Cannot get length of present monitor

I’ve a easy AppleScript for beginning a random video on a random place in Music.app as Automator software and as a startup login merchandise. Within the half of instances I get an error:

The motion “Run AppleScript” encountered an error: “Music bought an error: Cannot get length of present monitor.”

If I run it within the Script Editor it executes appropriately.

I attempted so as to add “delay 5” earlier than the road “set Y to length of present monitor” however it did not assist. Additionally tried so as to add “if” situation to stop Music.app whether it is working earlier than beginning the script, however it additionally did not change something.

enter image description here

inform software "Music"
    run
    set tune repeat to all
    set shuffle enabled to true
    play playlist "Music Movies"
    delay 1
    set Y to length of present monitor
    set X to random quantity from 0 to Y
    set participant place to X
    activate
finish inform

The error typically seems on the following day if system was shutdown with the script:

inform software "Finder" to close down

I suppose that is in some way associated to the working state of Music.app on the second of shutting down the system, since after system startup all apps return to the identical state they had been earlier than shutting down, e.g. if I shut all my apps and restart the system utilizing Apple brand > Restart the script shall be executed appropriately and I will not see any errors on the display screen.

macOS Ventura 13.4

Thanks loads

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles