AppleScript에서 내게 필요한 옵션 화면 열기
3216 단어 MacOSXAppleScriptSwift
AppleScript
Script.scpttell application "System Preferences"
reveal anchor "Privacy_Accessibility" of pane id "com.apple.preference.security"
activate
end tell
스크립트를 실행하면 시스템 환경설정의 내게 필요한 옵션 화면이 열립니다.

스크립트 편집기 .app에서 시도하는 것이 좋습니다.

스크립트를 앱에 통합
osascript
NSTask에서 명령을 실행하는 패턴.
NSTasklet path = "…/Script.scpt"
let task = NSTask()
task.launchPath = "/usr/bin/osascript"
task.arguments = [path]
task.launch()
위의 Swift 코드는 Terminal에서이 명령을 실행하는 것과 동일한 결과를 얻습니다.$ osascript ~/Desktop/Script.scpt
또는 NSAppleScript 클래스에서 실행할 패턴입니다. (미검증만 어디 어째서 좋았을까?)
NSAppleScriptlet path = "…/Script.scpt"
let script = NSAppleScript(contentsOfURL: NSURL(fileURLWithPath: path), error: nil)
let eventDescriptor = script?.executeAndReturnError(nil)
Reference
이 문제에 관하여(AppleScript에서 내게 필요한 옵션 화면 열기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/usagimaru/items/27deb753391d2c463213
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
tell application "System Preferences"
reveal anchor "Privacy_Accessibility" of pane id "com.apple.preference.security"
activate
end tell
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)
Reference
이 문제에 관하여(AppleScript에서 내게 필요한 옵션 화면 열기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/usagimaru/items/27deb753391d2c463213텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)