Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- Many thanks to those unknowing contributers that share their Applescript on the web. A few that helped with this script include:
- - Most of the UI Scripting came from Yoshimasa Niwa here: https://gist.github.com/4223249
- - Code for checking if an app is running came from here: http://codesnippets.joyent.com/posts/show/1124
- ####n8henrie Sat Mar 16 14:41:41 MDT 2013
- * Added several delays that seemed to be responsible for breaking this script in iTunes 11
- ####n8henrie Sun Mar 17 09:57:47 MDT 2013
- * Added compatibility with iTunes 10 (untested, please confirm if you can)
- * Added compatibility with having the iTunes sidebar activated (thanks to mattb in the comments)
- *)
- -- Check if iTunes is running. If not, start it up and give it 30 seconds to get in gear.
- repeat while not isItunesRunning()
- tell application "iTunes" to activate
- delay 30
- end repeat
- -- In case anything has stolen focus during the delay, bring it back into focus. I do this several times, after most delays.
- tell application "iTunes" to activate
- delay 1
- --CMD 7 to get to the "Apps" screen
- tell application "System Events" to keystroke "7" using command down
- delay 5
- tell application "iTunes" to activate
- delay 1
- --CMD r to check for update apps
- tell application "System Events" to keystroke "r" using command down
- delay 10
- tell application "iTunes" to activate
- delay 1
- --Now for clicking the "Download All Free Updates" button and the "are you old enough" dialog box that often comes afterward.
- tell application "System Events"
- tell process "iTunes"
- set frontmost to true
- delay 1
- tell window 1
- tell splitter group 1
- -- If the sidebar is activated
- if exists splitter group 1 then
- tell splitter group 1
- -- Compatibility with iTunes 10
- if exists UI element "iTunes store" then
- tell UI element "iTunes store"
- tell UI element "Download All Free Updates"
- if exists then perform action "AXPress"
- end tell
- end tell
- -- for iTunes 11
- else if exists UI element "loading iTunes store" then
- tell UI element "loading iTunes store"
- tell UI element "Download All Free Updates"
- if exists then perform action "AXPress"
- end tell
- end tell
- end if
- end tell
- -- If the sidebar is not activated
- else
- -- Compatibility with iTunes 10
- if exists UI element "iTunes store" then
- tell UI element "iTunes store"
- tell UI element "Download All Free Updates"
- if exists then perform action "AXPress"
- end tell
- end tell
- -- for iTunes 11
- else if exists UI element "loading iTunes store" then
- tell UI element "loading iTunes store"
- tell UI element "Download All Free Updates"
- if exists then perform action "AXPress"
- end tell
- end tell
- end if
- end if
- end tell
- end tell
- end tell
- end tell
- on isItunesRunning()
- tell application "System Events" to (name of processes) contains "iTunes"
- end isItunesRunning
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement