Created
August 15, 2013 00:03
Script to automate XCode installation. Tested on OSX 10.8.4 Mountain Lion. I feel like using the UI element hierarchy is quite disgusting, but it works for now...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Function to select a menu item | |
-- We will use this to trigger the search box for the App Store | |
on do_menu(app_name, menu_name, menu_item) | |
try | |
-- bring the target application to the front | |
tell application app_name | |
activate | |
end tell | |
tell application "System Events" | |
tell process app_name | |
tell menu bar 1 | |
tell menu bar item menu_name | |
tell menu menu_name | |
click menu item menu_item | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
return true | |
on error error_message | |
return false | |
end try | |
end do_menu | |
-- Launch the App Store & make sure it's focused | |
tell application "App Store" | |
launch | |
set frontmost to true | |
delay 1 | |
end tell | |
-- Search for the XCode app | |
do_menu("App Store", "Store", "Search") | |
tell application "System Events" to tell process "App Store" | |
keystroke "XCode" & return | |
tell window "App Store" | |
try | |
repeat until exists button 1 of group 1 of group 4 of list 1 of group 2 of UI element 1 of scroll area 1 | |
delay 0.2 | |
end repeat | |
set bName to name of button 1 of group 1 of group 4 of list 1 of group 2 of UI element 1 of scroll area 1 | |
if bName is "FREEFREE" then | |
tell group 1 of group 4 of list 1 of group 2 of UI element 1 of scroll area 1 | |
click button "FREEFREE" | |
repeat until exists button "INSTALL APPFREE" | |
delay 0.2 | |
end repeat | |
click button "INSTALL APPFREE" | |
end tell | |
repeat until exists text field "Password" of sheet 1 | |
delay 0.2 | |
end repeat | |
if exists (text field "Password" of sheet 1) then | |
keystroke "YOUR APPLE ID HERE" & tab | |
keystroke "YOUR PASSWORD HERE" & return | |
end if | |
else if bName is "INSTALLEDINSTALLED" then | |
return "Already installed... doing nothing" | |
end if | |
on error theError | |
return theError | |
end try | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment