I’m trying to get this script to work (on Mavericks), with no success, the script stays in the loop forever:
launch application "iTunes"
set launchCompleted to false
repeat while not launchCompleted
tell application "System Events"
tell process "iTunes"
set launchCompleted to (exists entire contents of first UI element)
end tell
end tell
end repeat
What I want to achieve is for an applescript to continue only if an app (for example iTunes) has finished loading.
From what I understand “exists entire contents of first UI element” is the way to go - but it doesn’t work…
the problem with that is that it doesn’t wait until the application has finished launching/loading.
I’m using Sibelius 7 and it takes app. 10 seconds until Sibelius has finished loading/launching and I don’t want the AppleScript to continue until those X seconds has completed.
launch application "Sibelius 7"
repeat while application "Sibelius 7" is not running
delay 0.2
end repeat
say "now"
actually I’m in the process of going FROM Finale to Sibelius.
Sibelius is unfortunately not AppleScript:able - I’ve never worked with UI elements in AS, could you give me an code example of how it might look like?
launch application "Sibelius 7"
set launchCompleted to false
repeat while (not launchCompleted)
tell application "System Events"
tell process "Sibelius 7"
set launchCompleted to (exists entire contents of first menu bar)
end tell
end tell
end repeat
say "now"
In other situations as well, it would be good to be able to halt an AS until one application has finished launching/loading…
I’m “fortunate” not being very good in Finale, maybe that helps the switch.
“(exists window 1)” doesn’t work since the Sibelius opening window (before it has finished launching) trigs it.
launch application "Sibelius 7"
set launchCompleted to false
repeat while (not launchCompleted)
tell application "System Events"
tell process "Sibelius 7"
set launchCompleted to (exists window 1)
end tell
end tell
end repeat
say "now"
launch application "Finale 2014"
set launchCompleted to false
repeat while (not launchCompleted)
tell application "System Events"
tell process "Finale 2014"
set launchCompleted to (exists menu 1 of menu bar 1)
end tell
end tell
end repeat
say "now"
launch application "Sibelius 7"
set launchCompleted to false
repeat while (not launchCompleted)
tell application "System Events"
tell process "Sibelius 7"
set launchCompleted to (exists menu 1 of menu bar 1)
end tell
end tell
end repeat
say "now"
I guess this SHOULD work… - Sibelius is acting strangely here…
launch application "Sibelius 7"
set launchCompleted to false
repeat while (not launchCompleted)
tell application "System Events"
tell process "Sibelius 7"
set launchCompleted to (exists third UI element)
end tell
end tell
end repeat
say "now"