Skip to content

Instantly share code, notes, and snippets.

@pwc3
Created March 25, 2014 03:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pwc3/9754730 to your computer and use it in GitHub Desktop.
Save pwc3/9754730 to your computer and use it in GitHub Desktop.
set appleID to "ENTER YOUR APPLE ID HERE"
activate application "Xcode"
tell application "System Events"
tell process "Xcode"
-- open the preferences dialog
click menu item "Preferences…" of menu "Xcode" of menu bar 1
-- find and select the Accounts tab
set found to false
repeat with aButton in buttons of toolbar 1 of window 1
if name of aButton is equal to "Accounts" then
set found to true
click aButton
end if
end repeat
-- bail if we couldn't find it
if not found then
display alert "Could not find \"Accounts\" tab in preferences window"
return
end if
-- find and select the cell with the specified Apple ID
set found to false
repeat with aRow in row of table 1 of scroll area 1 of window 1
if name of first UI element of aRow is equal to appleID then
set found to true
select aRow
end if
end repeat
-- bail if we couldn't find it
if not found then
display alert "Could not find \"" & appleID & "\" in preferences window"
return
end if
-- if the details sheet isn't already open...
if (count of sheets of window 1) is 0 then
-- find and click "View Details..."
set found to false
repeat with aButton in buttons of group 1 of window 1
if name of aButton is equal to "View Details..." then
set found to true
click aButton
end if
end repeat
if not found then
display alert "Could not find \"View Details...\" button"
return
end if
end if
-- find the Refresh and Done buttons
set refreshButton to missing value
set doneButton to missing value
repeat with aButton in buttons of sheet 1 of window 1
if description of aButton is equal to "refresh" then
set refreshButton to aButton
else if name of aButton is equal to "Done" then
set doneButton to aButton
end if
end repeat
-- bail if either could not be found
if refreshButton is missing value then
display alert "Could not find Refresh button"
return
end if
if doneButton is missing value then
display alert "Could not find Done button"
return
end if
-- click the Refresh button
click refreshButton
delay 3
-- click the Done button
click doneButton
delay 0.5
-- close the Preferences window
keystroke "w" using command down
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment