Skip to content

Instantly share code, notes, and snippets.

@mlongval
Last active February 3, 2016 14:46
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 mlongval/10985693 to your computer and use it in GitHub Desktop.
Save mlongval/10985693 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link

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
Copy link

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