[AppleScript] システム設定>プライバシーとセキュリティ>プライバシーとセキュリティ>フルディスクアクセスを開く
【スクリプトエディタで開く】 |
2_フルディスクアクセスを開く.applescript.scpt | ソース |
|---|
| 001 | #!/usr/bin/env osascript |
| 002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 003 | (* |
| 004 |
|
| 005 | システム設定の |
| 006 | プライバシーとセキュリティ>プライバシーとセキュリティ>フルディスクアクセス |
| 007 | を |
| 008 | 開きます |
| 009 |
|
| 010 | com.cocolog-nifty.quicktimer.icefloe *) |
| 011 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
| 012 | use AppleScript version "2.8" |
| 013 | use framework "Foundation" |
| 014 | use framework "AppKit" |
| 015 | use framework "UniformTypeIdentifiers" |
| 016 | use scripting additions |
| 017 | property refMe : a reference to current application |
| 018 | set strBundleID to ("com.apple.systempreferences") as text |
| 019 | ###URLにする |
| 020 | set ocidURLComponents to refMe's NSURLComponents's alloc()'s init() |
| 021 | ###スキーム |
| 022 | ocidURLComponents's setScheme:("x-apple.systempreferences") |
| 023 | ###パネルIDをパスにセット |
| 024 | ocidURLComponents's setPath:("com.apple.settings.PrivacySecurity.extension") |
| 025 | ###アンカーをクエリーとして追加 |
| 026 | ocidURLComponents's setQuery:("Privacy_AllFiles") |
| 027 | set ocidOpenAppURL to ocidURLComponents's |URL| |
| 028 | set strOpenAppURL to ocidOpenAppURL's absoluteString() as text |
| 029 | ###ワークスペースで開く |
| 030 | set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace() |
| 031 | set boolDone to appShardWorkspace's openURL:(ocidOpenAppURL) |
| 032 | log boolDone |
| 033 | if boolDone is false then |
| 034 | tell application id "com.apple.systempreferences" |
| 035 | activate |
| 036 | set miniaturized of the settings window to false |
| 037 | end tell |
| 038 | tell application id "com.apple.finder" |
| 039 | open location "x-apple.systempreferences:com.apple.settings.PrivacySecurity.extension?Privacy_AllFiles" |
| 040 | end tell |
| 041 | tell application id "com.apple.systempreferences" |
| 042 | reveal anchor "Privacy_AllFiles" of pane id "com.apple.settings.PrivacySecurity.extension" |
| 043 | end tell |
| 044 | tell application id "com.apple.systempreferences" to activate |
| 045 | end if |
| 046 | ###開くのを待つ |
| 047 | repeat 10 times |
| 048 | tell application id "com.apple.systempreferences" |
| 049 | set boolFrontMost to frontmost as boolean |
| 050 | end tell |
| 051 | if boolFrontMost is true then |
| 052 | delay 1 |
| 053 | exit repeat |
| 054 | else |
| 055 | tell application id "com.apple.systempreferences" to activate |
| 056 | delay 0.5 |
| 057 | end if |
| 058 | end repeat |
| 059 | ###パネルを確認して |
| 060 | repeat 10 times |
| 061 | tell application id "com.apple.systempreferences" |
| 062 | activate |
| 063 | tell current pane |
| 064 | set strPaneID to id |
| 065 | end tell |
| 066 | end tell |
| 067 | if strPaneID is "com.apple.systempreferences.GeneralSettings" then |
| 068 | delay 0.5 |
| 069 | else if strPaneID is "com.apple.settings.PrivacySecurity.extension" then |
| 070 | exit repeat |
| 071 | end if |
| 072 | end repeat |
| 073 | ###アンカーを再指定 |
| 074 | tell application "System Settings" |
| 075 | tell pane id "com.apple.settings.PrivacySecurity.extension" |
| 076 | tell anchor "Privacy_AllFiles" |
| 077 | try |
| 078 | reveal |
| 079 | end try |
| 080 | end tell |
| 081 | end tell |
| 082 | end tell |
| 083 | return 0 |
| AppleScriptで生成しました |
|---|