0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

AppScriptでトラックパッドとマウス環境を切り替える

Last updated at Posted at 2022-01-29

MacBookを自宅はマウス・外はトラックパッドを使うときにスクロール方向が違う:japanese_goblin:
(Logicoolなんかはソフトウェアで対応してる)
で,スクロール方向を切り替えるために[システム環境設定]->[トラックパッド]->[スクロールの方向: ナチュラル]とやっていた訳だが,AppScriptで自動化出来そうだということがわかった.

環境

macOS Monterey 12.2

手順

  1. AppScriptでスクロール方向を切り替えるスクリプトを記述する
  2. コードをアプリケーションとして書き出す
  3. ワンクリックで実行させるために「ショートカット.app」で書き出したアプリケーションを起動するプログラムを組む

スクロール方向を切り替えるスクリプト

参考にさせて頂いたサイト

set didRunSystemPreferences to get running of application "System Preferences"

tell application "System Preferences"
	set current pane to pane "com.apple.preference.trackpad"
	tell application "System Events" to tell tab group 1 of window "トラックパッド" of application process "System Preferences"
		click checkbox 1
	end tell
end tell

if not didRunSystemPreferences then
	quit application "System Preferences"
end if

スクリーンショット 2022-01-29 14.07.46.png
Spotlightを開いて「スクリプトエディタ」と入力しEnter.
新規資料作成で上記のコードをペースト.
スクリーンショット 2022-01-29 14.06.32.png

書き出し

メニューバーの[ファイル]->[書き出す]をクリック
スクリーンショット 2022-01-29 14.06.39.png
表示されたダイアログから***保存先(場所)***を[アプリケーション]に指定し,[ファイルフォーマット]をアプリケーションにし[保存]
スクリーンショット 2022-01-29 14.06.55.png

権限設定

[システム環境設定]->[セキュリティとプライバシー]->[アクセシビリティ]に移動しボタンを押して先ほど書き出したアプリケーションを追加します.
スクリーンショット 2022-01-29 14.07.33.png

ワンクリックで起動

ショートカット.appを開いて[メニューバー]から+を押します
スクリーンショット 2022-01-29 14.08.44.png
右側の[スクリプティング]をクリックして[AppScriptを実行]をドロップします.
スクリーンショット 2022-01-29 14.08.55.png
以下のコードを貼り付ける("toggleTrackpad"は書き出したアプリケーション名です)

tell application "toggleTrackpad"
	activate
end tell

スクリーンショット 2022-01-29 14.09.28.png

確認

メニューバーに追加されていれば成功です.
スクリーンショット 2022-01-29 14.09.43.png

最後に

快適なMacBookライフを

参考にさせて頂いたサイト

https://qiita.com/satosystems/items/8fff5b2313ecd6f81af3
https://zenn.dev/rot1024/articles/mac_keyboard_layout_monterey

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?