![見出し画像](https://assets.st-note.com/production/uploads/images/54961159/rectangle_large_type_2_b6276d2e3972b8ec37112c3992bdfdbc.png?width=1200)
Macをグレイスケール表示する
「スマートフォンへの依存を防ぐにはグレースケール設定が効果的?」という話題がありました。
写真編集などは論外ですが、テキスト中心の作業のとき、カラーにしておく必要はありません。
システム環境設定の[アクセシビリティ]内の[グレイスケールを使用]にて設定できるのですが、サクっとON/OFFできないと困ります。
![画像1](https://assets.st-note.com/production/uploads/images/54958800/picture_pc_9e2241515a88bcd92d64418c5693f503.png?width=1200)
AppleScriptで解決する
同じようなことを考えている人がいるのか、各OSごとAppleScriptのコードが見つかります。
macOSの言語を英語にしていればいいのですが、日本語では動かない… と困っていたのですが、解決できました。
# 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
というソースコードを次のように書き換えます。
# 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 "アクセシビリティ"
tell scroll area 1 to tell table 1 to tell row 6 #open display preferences
select
end tell
tell group 1
click checkbox "グレイスケールを使用"
end tell
end tell
end tell
tell application "System Preferences" to quit
つまり、システム環境設定を開いたあとは、画面上の文言をそのまま指定すればよい、ということみたいです。
Keyboard Maestroでマクロにする
Keyboard Maestroでマクロにしてhot keyを設定すればトグルします。
![画像2](https://assets.st-note.com/production/uploads/images/54959346/picture_pc_008f9c0d56aaadba2e2cbd4e321d2137.png?width=1200)
ダウンロード
Keyboard Maestroのマクロ
効果があるのか?
グレイスケールにすることで集中力が高まり、目にも少しやさしいかもしれません。サクっとON/OFFできるようになったので、実際、どんなものか検証してみたいと思います。
備考
macOSでは「グレー」でなく「グレイ」。
macOS Monterey(12)への対応
macOS Monterey(12)で大きくインターフェイスが変わりました。
![](https://assets.st-note.com/img/1645969886912-ulGx3dSntT.png?width=1200)
動かなくて困っていたのですが、axpensiveさんの記事にて糸口を得られました。
言語がUSのため修正が必要で、次のようにしたところ、動きました。
# System PreferencesのAccessibilityを開きます。
tell application "System Preferences"
launch
reveal anchor "Seeing_ColorFilters" of pane "アクセシビリティ"
end tell
tell application "System Events"
tell application process "System Preferences"
delay 1
tell window "アクセシビリティ"
# 設定画面が出るまで待ちます。
repeat until exists checkbox "カラーフィルタを有効にする" of tab group 1 of group 1
delay 0.01
end repeat
# グレースケールをon/offします。
click first checkbox of tab group 1 of group 1
end tell
end tell
end tell
# windowを閉じます。
tell application "System Preferences" to if it is running then quit
macOS Monterey(12)対応版のKeyboard Maestroマクロを置いておきます。
追記
macOS Ventura(13)では、システム環境設定のUIが大きく変わりました。上記のAppleScriptは動きません。
Self Factoryさんが紹介されている「ショートカット」を使う方法がよさそうです(やってみたけど、エラーが出て動かず…)。
ここから先は
![](https://assets.st-note.com/production/uploads/images/7425662/profile_a5ee2a599e9dc5d7e0de3dfdbdf04018.jpg?fit=bounds&format=jpeg&quality=85&width=330)
DTP Transit 定期購読マガジン
マガジン限定記事やサンプルファイルをダウンロードできます。
定期マガジンを購読されるとサンプルファイルをダウンロードいただけます。 https://note.com/dtp_tranist/m/mebd7eab21ea5