Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MacOSX Grayscale Mode Toggle Applescript
(*
ToggleGrayScaleMode for MacOSX 10.9 Mavericks
works as of 15 april 2014
This is an AppleScript UI script to toggle GrayScaleMode in System Preferences.
I am red-green colorblind and grayscale helps a lot...
Works for me. Hope it can be usefull for you.
Mike
mlongval@gmail.com
*)
tell application "System Preferences"
activate
tell application "System Events"
tell application process "System Preferences"
set frontmost to true
delay 1
click menu item "Accessibility" of menu "View" of menu bar item "View" of menu bar 1 of application process "System Preferences" of application "System Events"
-- add delay if needed
delay 1
-- The MAGIC word here is SELECT .... you are SELECTing a row NOT CLICKing a row !!!!!!!!!
select row 2 of table 1 of scroll area 1 of window "Accessibility" of application process "System Preferences" of application "System Events"
-- Now you can CLICK the checkbox
click checkbox "Use grayscale" of window "Accessibility" of application process "System Preferences" of application "System Events"
-- add delay if needed
delay 1
click menu item "Quit System Preferences" of menu "System Preferences" of menu bar item "System Preferences" of menu bar 1 of application process "System Preferences" of application "System Events"
end tell
end tell
end tell
@mlongval

This comment has been minimized.

Copy link
Owner Author

@mlongval mlongval commented Apr 17, 2014

Ok well, I made it through the complicated naming of Apple UI Objects.
Here is a simple script to toggle grayscale.... for all us colorblind folk out there.
Cheers.

@janthenat

This comment has been minimized.

Copy link

@janthenat janthenat commented Jan 13, 2015

In the interest of simplifying... How about this?
(sorry, don't know how to post applescript code properly)

tell application "System Preferences"
activate
reveal anchor "Seeing_Display" of pane "Accessibility"
tell application "System Events" to tell process "System Preferences"
click checkbox "Use grayscale" of window 1
end tell
quit application "System Preferences"
end tell

@jkulesza

This comment has been minimized.

Copy link

@jkulesza jkulesza commented Feb 3, 2016

Thanks for developing this! I had another script (similar to @janthenat's); however, it stopped working with El Capitan.

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.