download - Applescript: Wait for an action/event to complete -


i writing script download free/non-free applications itunes store. each download , taking 5 10 seconds.

for example:

repeat 1000 times

download_app()

end repeat

on download_app()

download stuff ....

delay 10

end download_app

for downloading 1 application 1000 times, taking big amount of time , want optimize timing. instead of using delay 10, there other way ?

is there way downloading status / busy status of itunes?

please suggest.

advanced thanks

rahman

i don't have specific solution, following code may provide useful example:

tell application "system events"     tell application process "safari"         repeat             if (accessibility description of (get properties of button 1 of text field 1 of splitter group 1 of group 2 of tool bar 1 of window 1)) not contain "stop" exit repeat         end repeat     end tell end tell 

this code pauses script until webpage has finished loading. entering infinite loop , breaking out of loop upon reaching condition.

the condition appears rather complex, checks simple. @ right side of safari url field there's stop/reload button. while page loading, shows stop icon. once page stops loading, shows reload icon. hence, when no longer see stop icon, page must have finished loading.

most of code rather cryptically navigates gui identify button described. term accessibility description used identify current state of button. accessibility description spoken aloud handicapped (e.g. visually impaired) individuals running mac os x under accessibility mode. naturally, while page loading button described "stop."

if interactive aspect of itunes gui changes (most button) when download completes, can detect change of state in similar fashion , use cue continue script.

hope helps. (my example implementation of code. have found ridiculously precise—the script continues instantaneously after page finishes loading.)

disclosure: not original code—i found somewhere on internet.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -