Instantly share code, notes, and snippets.

Embed
What would you like to do?
The only working applescript for toggling grayscale on in OSX Sierra in the world (probably)
tell application "System Preferences"
activate
set the current pane to pane id "com.apple.preference.universalaccess"
delay 1 # needs time to open universal access
tell application "System Events" to tell process "System Preferences" to tell window "Accessibility"
tell scroll area 2 to tell table 1 to tell row 6 #open display preferences
select
end tell
click checkbox "Use grayscale"
end tell
end tell
tell application "System Preferences" to quit
@agsadasfs

This comment has been minimized.

agsadasfs commented Sep 19, 2018

I was getting an error for High Sierra 10.13.1 - I fixed it by adding an extra line. Take a look.

tell application "System Preferences"
	activate
	reveal (pane id "com.apple.preference.universalaccess")
end tell

tell application "System Events"
	tell process "System Preferences"
		tell window "Accessibility"
			tell table 1 of scroll area 1
				-- Added "delay 1" to work in 10.11 - El Capitan
				delay 1
				select (row 2)
			end tell
			tell scroll area 2 to tell table 1 to tell row 6 #open display preferences
				select
			end tell
			click checkbox "Use grayscale"
		end tell
	end tell
end tell
tell application "System Preferences" to quit
@wbw1006

This comment has been minimized.

wbw1006 commented Nov 10, 2018

can get window "Accessibility" of process "System Preferences

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment