20260427

システム設定>一般>デバイス管理を開く

システム設定>一般>デバイス管理を開く

NOTE記事一覧ですnote.com

【スクリプトエディタで開く】 |

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