Created
December 24, 2019 15:30
-
-
Save mmertsock/db09ca302cc38d805d86a06aecb3335a to your computer and use it in GitHub Desktop.
AppleScript to pick a random macOS accent color
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
-- https://apple.stackexchange.com/a/338355/13458 | |
tell application "System Preferences" | |
reveal anchor "Main" of pane id "com.apple.preference.general" | |
end tell | |
tell application "System Events" | |
repeat until exists of checkbox "Dark" of window "General" of application process "System Preferences" | |
delay 0.1 | |
end repeat | |
set accentColors to {"Blue", "Purple", "Pink", "Red", "Orange", "Yellow", "Green", "Graphite"} | |
repeat with a from 1 to 5 | |
set randIndex to random number from 1 to count of accentColors | |
set theColor to item randIndex of accentColors | |
set isColorSelected to value of checkbox theColor of window "General" of application process "System Preferences" | |
if isColorSelected is 0 then | |
click checkbox theColor of window "General" of application process "System Preferences" | |
exit repeat | |
end if | |
end repeat | |
end tell | |
tell application "System Preferences" to quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment