The subject tells you what I want my script to do.
I’m really new to scripting, I started learning about scripts with this website, so be patient! I tried to write my own script. Here it is:
try
tell application "iTunes" to set Canzone to the name of current track
on error
display dialog "iTunes was not running!" giving up after 5
tell me to quit
end try
on idle
tell application "iTunes"
if (name of current track) is not Canzone then
display dialog "Chiudo iTunes?" buttons {"No", "Si"} default button "Si" giving up after 10
if button returned of result = "Si" then
quit
tell me to quit
end if
end if
end tell
return 15
end idle
I saved it as an Application, with the option “Do not quit”. But when I run it, I get an error:“The variable Canzone is not defined”
I thought that this is because I defined it outside the “on idle” block, so I tried with a repeat statement instead of “on idle”, like this:
try
tell application "iTunes" to set Canzone to the name of current track
on error
display dialog "iTunes was not running!" giving up after 5
tell me to quit
end try
repeat
tell application "iTunes"
if (name of current track) is not equal to Canzone then
display dialog "Chiudo iTunes?" buttons {"No", "Si"} default button "Si" giving up after 10
if button returned of result = "Si" then
tell application "iTunes" to quit
exit repeat
end if
else
delay 15
end if
end tell
end repeat
Like this, it works, but only if I click on the “Si” button. Despite the "default button “Si” " if I wait 10 seconds the dialog appears again, and iTuns doesn’t quit.
Where is my mistake? I’m sorry, I know this is a stupid question but keep in mind I’m at the very beginning…