Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The only working applescript for toggling grayscale on in OSX Sierra and Mojave in the world (probably)
# for osx mojave
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 1 to tell table 1 to tell row 6 #open display preferences
select
end tell
tell group 1
click checkbox "Use grayscale"
end tell
end tell
end tell
tell application "System Preferences" to quit
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.

Copy link

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.

Copy link

wbw1006 commented Nov 10, 2018

can get window "Accessibility" of process "System Preferences

@1404423

This comment has been minimized.

Copy link

1404423 commented May 22, 2019

Now I can't use this code.
If possible I'd like to know the script which turns off and on 3 finger drag.

@silesky

This comment has been minimized.

Copy link
Owner Author

silesky commented Jun 5, 2019

Updated this for OSX Mojave.
@1404423, that should be possible by tweaking this script.

@KDALEX

This comment has been minimized.

Copy link

KDALEX commented Sep 14, 2019

For Mac OS 10.14.4 (18E227) I had to change line 11 of the first script to "click checkbox 2".

@Giulianini

This comment has been minimized.

Copy link

Giulianini commented Apr 28, 2020

Can you make it for Catalina? it would be very useful

@kevin-deyoungster

This comment has been minimized.

Copy link

kevin-deyoungster commented May 1, 2020

Thanks @silesky for pointing in the right direction. Here's what I came up with for Catalina (@Giulianini)

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"
		select row 5 of table 1 of scroll area 1 #open display preferences
		click radio button "Colour Filters" of tab group 1 of group 1
		click checkbox "Enable Colour Filters" of tab group 1 of group 1
	end tell
end tell
tell application "System Preferences" to quit
@Giulianini

This comment has been minimized.

Copy link

Giulianini commented May 1, 2020

Schermata 2020-05-01 alle 21 51 07

Thanks @kevin-deyoungster but i ran into this error "Impossible to obtain window "Accessibility" of process "System Preferences"". It happened to me a lot of times and I can't face the problem. In my opinion there is a problem in Catalina

@kevin-deyoungster

This comment has been minimized.

Copy link

kevin-deyoungster commented May 1, 2020

Oh, I see the issue, your language setting is different.

You'll need to change the strings Accessibility, Colour Filters and Enable Colour Filters to the right translations, the ones your system uses.

I assume you're using Italian so change:
Accessibility -> Accessibilità
Colour Filters -> Filtri colore
Enable Colour Filters -> Abilita filtri colore

Hope it helps, let know how it goes!

Schermata 2020-05-01 alle 21 51 07

Thanks @kevin-deyoungster but i ran into this error "Impossible to obtain window "Accessibility" of process "System Preferences"". It happened to me a lot of times and I can't face the problem. In my opinion there is a problem in Catalina

@Giulianini

This comment has been minimized.

Copy link

Giulianini commented May 1, 2020

@kevin-deyoungster you save my day. I have done a very similar setting yesterday but i kept Enable (C)olor (F)ilters capitalized but in Italian it's lowercase. I must definitely change language settings to English. Thanks again for the help!

@kevin-deyoungster

This comment has been minimized.

Copy link

kevin-deyoungster commented May 1, 2020

Glad that helped. You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.