7
7

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 5 years have passed since last update.

AppleScript でアクセシビリティ画面を開く

Last updated at Posted at 2016-05-16

AppleScript

Script.scpt
tell application "System Preferences"
	reveal anchor "Privacy_Accessibility" of pane id "com.apple.preference.security"
	activate
end tell

スクリプトを実行するとシステム環境設定のアクセシビリティ画面が開きます。

スクリプトエディタ.app で試すのがいいです。

スクリプトをアプリに組み込む

osascript コマンドを NSTask で実行するパターン。

NSTask
let path = "…/Script.scpt"
let task = NSTask()
task.launchPath = "/usr/bin/osascript"
task.arguments = [path]
task.launch()

上の Swift コードは Terminal でこのコマンドを実行するのと同じ結果になります。
$ osascript ~/Desktop/Script.scpt

あるいは NSAppleScript クラスで実行するパターン。(未検証だけどこんなんでよかったか?)

NSAppleScript
let path = "…/Script.scpt"
let script = NSAppleScript(contentsOfURL: NSURL(fileURLWithPath: path), error: nil)
let eventDescriptor = script?.executeAndReturnError(nil)
7
7
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
7
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?