If anyone still want updates, then just say so. I have some ideas on error checking. There is one update you should make though. change the last iTunes tell block to:
tell application "iTunes"
activate
play
reveal current track
end tell
Because, you want to see the currently playing track.
set is_running to application "iTunes" is running
if is_running then
display dialog "iTunes is running.
The script can't run if iTunes is running (maybe)
Do you want to quit iTunes or relaunch?"
end if
If anyone is interested, I found a bug with the script here in Yosemite. If the current space is space 5 then it gets stuck. It might have been there all the time, but working on the fix. Don’t know yet.
I might switch to your method of switching spaces. It might be more stable. Any change by Apple in the ui and you have to debug it again when using ui element scripting. That’s the problem maybe.
Although, it was so much more easier, in the long run you lose because you need to continuously update on each upgrade to the os.
I need to look again at your long long long script.