AppleScript System Settings

システム設定をオープンさせるスクリプトの作成補助v4


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#システム設定オープン用のスクリプト作成補助 v4
# 作成されるスクリプトにウィンドウの最小化を解除する手順を入れた
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set strBundleID to "com.apple.systempreferences" as text


############################
###【1】システム設定の起動を確定させる
set ocidRunAppArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
if (count of ocidRunAppArray) ≠ 0 then
log "起動中です"
  tell application id strBundleID to activate
else
  ####ゾンビ対策終了させてから処理させる
  tell application id strBundleID
    set numCntWindow to (count of every window) as integer
  end tell
  if numCntWindow = 0 then
    tell application id strBundleID to quit
  else
    tell application id strBundleID
close (every window)
quit
    end tell
  end if
  ####半ゾンビ化対策
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
  ###システム設定を起動させる
  try
    tell application id strBundleID to activate
  on error
    tell application "System Settings" to activate
  end try
  ###起動待ち
  tell application id strBundleID
    ###起動確認 最大10秒
    repeat 10 times
activate
      set boolFrontMost to frontmost as boolean
log boolFrontMost
      if boolFrontMost is true then
        ###魔法の1秒
delay 0.5
        exit repeat
      else
delay 0.5
      end if
    end repeat
  end tell
end if
############################
###【2】全てのパネルのIDを取得
tell application id "com.apple.systempreferences"
  set listPanelID to (id of every pane) as list
end tell

############################
###【A】正順レコード
set ocidPaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【B】逆順レコード
set ocidReversePaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【3】1で取得したリストの数だけ繰り返し
repeat with itemPanelID in listPanelID
  set strPanelID to itemPanelID as text
  tell application "System Settings"
    set strPanelName to (name of pane id strPanelID) as text
  end tell
  ###【A】正順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelName) forKey:(strPanelID))
(ocidPaneDict's addEntriesFromDictionary:(ocidItemDict))
  ###【B】逆順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelID) forKey:(strPanelName))
(ocidReversePaneDict's addEntriesFromDictionary:(ocidItemDict))
end repeat

############################
###【4】ダイアログ用に正順レコードのLISTを作る
set ocidAllValueArray to ocidPaneDict's allValues()
##ソートしておく
set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("self") ascending:(true) selector:("localizedStandardCompare:")
set ocidDescriptorArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidDescriptorArray's addObject:(ocidDescriptor)
set ocidSortedKey to (ocidAllValueArray's sortedArrayUsingDescriptors:(ocidDescriptorArray))
set listAllValueArray to ocidSortedKey as list
############################
###【5】ダイアログ  パネル
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listAllValueArray with title "選んでください" with prompt "選択したパネルを開きます" default items (item 1 of listAllValueArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strResponse to (item 1 of listResponse) as text
end if
log strResponse
############################
###【6】戻り値を逆順リストで検索してパネルIDを取得
set ocidPaneID to ocidReversePaneDict's valueForKey:(strResponse)
set strPaneID to ocidPaneID as text
log "strPaneID" & strPaneID
############################
###【7】アンカーの値の取得
tell application "System Settings"
  set listPaneAnchor to (name of anchors of pane strResponse) as list
log listPaneAnchor
end tell
###【7−1】一般選択時のみアンカーが無い
if strResponse is "一般" then
  set listPaneAnchor to {"Main"} as list
end if
############################
###【8】ダイアログ アンカー
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listPaneAnchor with title "選んでください" with prompt "選択したアンカーを開きます" default items (item 1 of listPaneAnchor) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strPaneAnchor to (item 1 of listResponse) as text
end if
log strPaneAnchor


############################
###【9】URLにする
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム
ocidURLComponents's setScheme:("x-apple.systempreferences")
###パネルIDをパスにセット
ocidURLComponents's setPath:(ocidPaneID)
###アンカーをクエリーとして追加
ocidURLComponents's setQuery:(strPaneAnchor)
set ocidOpenAppURL to ocidURLComponents's |URL|
set strOpenAppURL to ocidOpenAppURL's absoluteString() as text
log strOpenAppURL

############################
###【10】ワークスペースで開く
###ファイルURLとパネルのURLをArrayにしておく
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidOpenUrlArray's insertObject:(ocidOpenAppURL) atIndex:0
###FinderでURLを開くのでFinderのURLを用意
set strBundleID to "com.apple.finder" as text
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
###NSWorkspaceで開く
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
ocidOpenConfig's setAllowsRunningApplicationSubstitution:(refMe's NSNumber's numberWithBool:true)
appShardWorkspace's openURLs:(ocidOpenUrlArray) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)

####システム設定が前面に来るまで待つ
repeat 20 times
  set boolFrontMost to frontmost of application id "com.apple.systempreferences"
  if boolFrontMost is false then
    tell application id "com.apple.systempreferences" to activate
  else
    exit repeat
  end if
delay 0.2
end repeat


#################################
###【11】ダイアログ用に値を用意
set strScript to ("#!/usr/bin/env osascript\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\n#com.cocolog-nifty.quicktimer.icefloe\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\nuse AppleScript version \"2.8\"\nuse framework \"Foundation\"\nuse framework \"AppKit\"\nuse framework \"UniformTypeIdentifiers\"\nuse scripting additions\nproperty refMe : a reference to current application\nset strBundleID to \"com.apple.systempreferences\" as text\n###URLにする\nset ocidURLComponents to refMe's NSURLComponents's alloc()'s init()\n###スキーム\nocidURLComponents's setScheme:(\"x-apple.systempreferences\")\n###パネルIDをパスにセット\nocidURLComponents's setPath:(\"" & strPaneID & "\")\n###アンカーをクエリーとして追加\nocidURLComponents's setQuery:(\"" & strPaneAnchor & "\")\nset ocidOpenAppURL to ocidURLComponents's |URL|\nset strOpenAppURL to ocidOpenAppURL's absoluteString() as text\n###ワークスペースで開く\nset appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()\nset boolDone to appShardWorkspace's openURL:(ocidOpenAppURL)\nlog boolDone\nif boolDone is false then\ntell application id \"com.apple.systempreferences\"\nactivate\nset miniaturized of the settings window to false\nend tell\ntell application id \"com.apple.systempreferences\"\nreveal anchor \"" & strPaneAnchor & "\" of pane id \"" & strPaneID & "\"\nend tell\ntell application id \"com.apple.finder\"\nopen location \"" & strOpenAppURL & "\"\nend tell\ntell application id \"com.apple.systempreferences\" to activate\nend if\nreturn\n")

#################################
###【12】戻り値ダイアログ
set strName to (name of current application) as text
log strName
if strName is "osascript" then
  repeat 20 times
    set boolFrontMost to frontmost of application "Finder"
    if boolFrontMost is false then
      tell application "Finder" to activate
    else
      exit repeat
    end if
delay 0.2
  end repeat
else
  repeat 5 times
    set boolFrontMost to frontmost of application "Script Editor"
log boolFrontMost
    if boolFrontMost is false then
      tell current application to activate
    else
      exit repeat
    end if
delay 0.2
  end repeat
  
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/ManagedClient.app/Contents/PlugIns/ConfigurationProfilesUI.bundle/Contents/Resources/SystemPrefApp.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "スクリプト戻り値です" with title "【3】スクリプト" default answer strScript buttons {"クリップボードにコピー", "キャンセル", "スクリプトエディタで開く"} default button "スクリプトエディタで開く" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)
#################################
###【13】クリップボードにコピー
if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if
#################################
###【14】OK押したらスクリプト生成
if button returned of recordResult is "スクリプトエディタで開く" then
  ##ファイル名
  set strFileName to (strResponse & "." & (ocidPaneID as text) & "." & strPaneAnchor & ".applescript") as text
  ##保存先はスクリプトメニュー
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidLibraryDIrURL to ocidURLsArray's firstObject()
  set ocidScriptDirPathURL to ocidLibraryDIrURL's URLByAppendingPathComponent:("Scripts/Applications/System Settings/Open")
  ###フォルダを作って
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidScriptDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  set ocidSaveFilePathURL to ocidScriptDirPathURL's URLByAppendingPathComponent:(strFileName)
  ###スクリプトをテキストで保存
  set ocidScript to refMe's NSString's stringWithString:(strScript)
  ##改行はLFで
  set ocidLFScript to ocidScript's stringByReplacingOccurrencesOfString:("\r") withString:("\n")
  # set ocidEnc to (refMe's NSUTF16LittleEndianStringEncoding)
  # ターミナルからの実行を配慮してUTF8に
  set ocidEnc to (refMe's NSUTF8StringEncoding)
  set listDone to ocidLFScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(ocidEnc) |error|:(reference)
delay 0.5
  set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
  ###ターミナルから実行できるように755に
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidSaveFilePathURL's |path|()) |error|:(reference)
  
  
  ###保存したスクリプトを開く
  tell application "Script Editor"
open aliasSaveFilePath
  end tell
end if



|

[com.apple.systempreferences]システム設定はlaunch→NG activate→OK

macOS14 現時点でのシステム設定の起動方法


tell application id "com.apple.systempreferences" to launch
-->launchするとストールする

tell application id "com.apple.systempreferences" to activate
-->launchしないでactivateで起動させるのが現時点で解決策

|

システム設定パネルID追加

PLIST2HTML:prefsmapping.plist.html macOS14追加
連番キーの名前キーの値
1com.apple.preferences.walletcom.apple.WalletSettingsExtension
2com.apple.preference.universalaccess&anchorId=Accessibility_Shortcutcom.apple.Accessibility-Settings.extension?Accessibility_Shortcut
3com.apple.preference.universalaccess&anchorId=Siricom.apple.Accessibility-Settings.extension?Siri
4com.apple.preference.universalaccess&anchorId=TextToSpeechcom.apple.Accessibility-Settings.extension?TextToSpeech
5com.apple.preference.universalaccess&anchorId=Seeing_Zoomcom.apple.Accessibility-Settings.extension?Seeing_Zoom
6com.apple.preference.trackpadcom.apple.Trackpad-Settings.extension
7com.apple.preference.universalaccess&anchorId=Seeing_VoiceOvercom.apple.Accessibility-Settings.extension?Seeing_VoiceOver
8com.apple.preference.securitycom.apple.settings.PrivacySecurity.extension
9com.apple.preference.screentimecom.apple.Screen-Time-Settings.extension
10com.apple.preferences.FamilySharingPrefPanecom.apple.Family-Settings.extension*Family
11com.apple.preference.universalaccess&anchorId=Media_Descriptionscom.apple.Accessibility-Settings.extension?Media_Descriptions
12com.apple.preference.universalaccesscom.apple.Accessibility-Settings.extension
13com.apple.preference.screentime&anchorId=Downtimecom.apple.Screen-Time-Settings.extension?path=downtime
14com.apple.preferences.Bluetoothcom.apple.BluetoothSettings
15com.apple.preferences.softwareupdatecom.apple.Software-Update-Settings.extension
16com.apple.preference.desktopscreeneffectcom.apple.Wallpaper-Settings.extension
17com.apple.prefs.backupcom.apple.Time-Machine-Settings.extension
18com.apple.preference.batterycom.apple.Battery-Settings.extension*BatteryPreferences
19com.apple.preference.networkcom.apple.Network-Settings.extension
20com.apple.preference.screentime&anchorId=AlwaysAllowedcom.apple.Screen-Time-Settings.extension?path=always-allowed
21com.apple.preferences.configurationprofilescom.apple.Profiles-Settings.extension
22com.apple.preference.screentime&anchorId=DailyUsagecom.apple.Screen-Time-Settings.extension?path=app-usage
23com.apple.preference.universalaccess&anchorId=Mousecom.apple.Accessibility-Settings.extension?Mouse
24com.apple.preferences.AppleIDPrefPanecom.apple.systempreferences.AppleIDSettings*AppleIDSettings
25com.apple.preferences.extensionscom.apple.ExtensionsPreferences
26com.apple.preference.notificationscom.apple.Notifications-Settings.extension
27com.apple.preference.keyboardcom.apple.Keyboard-Settings.extension
28com.apple.preference.dockcom.apple.Desktop-Settings.extension
29com.apple.preference.digihub.discscom.apple.CD-DVD-Settings.extension
30com.apple.preference.screentime&anchorId=ViewUsageLimitcom.apple.Screen-Time-Settings.extension?path=app-limits
31com.apple.preference.spotlightcom.apple.Siri-Settings.extension
32com.apple.preference.screentime&anchorId=ContentAndPrivacycom.apple.Screen-Time-Settings.extension?path=content-and-privacy
33com.apple.preference.universalaccess&anchorId=Switchcom.apple.Accessibility-Settings.extension?Switch
34com.apple.preferences.passwordcom.apple.Touch-ID-Settings.extension*TouchIDPasswordPrefs
35com.apple.Localizationcom.apple.Localization-Settings.extension
36com.apple.preference.universalaccess&anchorId=Seeing_Displaycom.apple.Accessibility-Settings.extension?Seeing_Display
37com.apple.preference.startupdiskcom.apple.Startup-Disk-Settings.extension
38com.apple.preference.speechcom.apple.Siri-Settings.extension
39com.apple.preference.datetimecom.apple.Date-Time-Settings.extension
40com.apple.preference.displayscom.apple.Displays-Settings.extension
41com.apple.preference.universalaccess&anchorId=Hearingcom.apple.Accessibility-Settings.extension?Hearing
42com.apple.preference.screentime&anchorId=DailyPickupscom.apple.Screen-Time-Settings.extension?path=pickups
43com.apple.preferences.ClassKitPreferencePanecom.apple.ClassKit-Settings.extension
44com.apple.preference.mousecom.apple.Mouse-Settings.extension
45com.apple.preferences.EnergySaverPrefPanecom.apple.Battery-Settings.extension
46com.apple.preferences.internetaccountscom.apple.Internet-Accounts-Settings.extension
47com.apple.preferences.sharingcom.apple.Sharing-Settings.extension
48com.apple.preference.universalaccess&anchorId=Captioningcom.apple.Accessibility-Settings.extension?Captioning
49com.apple.preference.screentime&anchorId=CommunicationLimitcom.apple.Screen-Time-Settings.extension?path=communication-limits
50com.apple.preference.universalaccess&anchorId=Dictationcom.apple.Accessibility-Settings.extension?Dictation
51com.apple.preference.printfaxcom.apple.Print-Scan-Settings.extension
52com.apple.preference.generalcom.apple.Appearance-Settings.extension
53com.apple.preference.screentime&anchorId=DailyNotificationscom.apple.Screen-Time-Settings.extension?path=notifications
54com.apple.preference.soundcom.apple.Sound-Settings.extension
55com.apple.preferences.userscom.apple.Users-Groups-Settings.extension
56com.apple.preference.universalaccess&anchorId=Keyboardcom.apple.Accessibility-Settings.extension?Keyboard
57com.apple.Passwordscom.apple.Passwords-Settings.extension
合計57項目
com.apple.helpviewer Plist情報:prefsmapping.plist.html
項番キーの名前キーの値
1com.apple.preferences.walletcom.apple.WalletSettingsExtension
2com.apple.preference.universalaccess&anchorId=Accessibility_Shortcutcom.apple.Accessibility-Settings.extension?Accessibility_Shortcut
3com.apple.preference.universalaccess&anchorId=Siricom.apple.Accessibility-Settings.extension?Siri
4com.apple.preference.universalaccess&anchorId=TextToSpeechcom.apple.Accessibility-Settings.extension?TextToSpeech
5com.apple.preference.universalaccess&anchorId=Seeing_Zoomcom.apple.Accessibility-Settings.extension?Seeing_Zoom
6com.apple.preference.trackpadcom.apple.Trackpad-Settings.extension
7com.apple.preference.universalaccess&anchorId=Seeing_VoiceOvercom.apple.Accessibility-Settings.extension?Seeing_VoiceOver
8com.apple.preference.securitycom.apple.settings.PrivacySecurity.extension
9com.apple.preference.screentimecom.apple.Screen-Time-Settings.extension
10com.apple.preferences.FamilySharingPrefPanecom.apple.Family-Settings.extension*Family
11com.apple.preference.universalaccess&anchorId=Media_Descriptionscom.apple.Accessibility-Settings.extension?Media_Descriptions
12com.apple.preference.universalaccesscom.apple.Accessibility-Settings.extension
13com.apple.preference.screentime&anchorId=Downtimecom.apple.Screen-Time-Settings.extension?path=downtime
14com.apple.preferences.Bluetoothcom.apple.BluetoothSettings
15com.apple.preferences.softwareupdatecom.apple.Software-Update-Settings.extension
16com.apple.preference.desktopscreeneffectcom.apple.Wallpaper-Settings.extension
17com.apple.prefs.backupcom.apple.Time-Machine-Settings.extension
18com.apple.preference.batterycom.apple.Battery-Settings.extension*BatteryPreferences
19com.apple.preference.networkcom.apple.Network-Settings.extension
20com.apple.preference.screentime&anchorId=AlwaysAllowedcom.apple.Screen-Time-Settings.extension?path=always-allowed
21com.apple.preferences.configurationprofilescom.apple.Profiles-Settings.extension
22com.apple.preference.screentime&anchorId=DailyUsagecom.apple.Screen-Time-Settings.extension?path=app-usage
23com.apple.preference.universalaccess&anchorId=Mousecom.apple.Accessibility-Settings.extension?Mouse
24com.apple.preferences.AppleIDPrefPanecom.apple.systempreferences.AppleIDSettings*AppleIDSettings
25com.apple.preferences.extensionscom.apple.ExtensionsPreferences
26com.apple.preference.notificationscom.apple.Notifications-Settings.extension
27com.apple.preference.keyboardcom.apple.Keyboard-Settings.extension
28com.apple.preference.dockcom.apple.Desktop-Settings.extension
29com.apple.preference.screentime&anchorId=ViewUsageLimitcom.apple.Screen-Time-Settings.extension?path=app-limits
30com.apple.preference.screentime&anchorId=ContentAndPrivacycom.apple.Screen-Time-Settings.extension?path=content-and-privacy
31com.apple.preference.spotlightcom.apple.Siri-Settings.extension
32com.apple.preference.digihub.discscom.apple.CD-DVD-Settings.extension
33com.apple.preference.universalaccess&anchorId=Switchcom.apple.Accessibility-Settings.extension?Switch
34com.apple.preferences.passwordcom.apple.Touch-ID-Settings.extension*TouchIDPasswordPrefs
35com.apple.Localizationcom.apple.Localization-Settings.extension
36com.apple.preference.universalaccess&anchorId=Seeing_Displaycom.apple.Accessibility-Settings.extension?Seeing_Display
37com.apple.preference.startupdiskcom.apple.Startup-Disk-Settings.extension
38com.apple.preference.speechcom.apple.Siri-Settings.extension
39com.apple.preference.datetimecom.apple.Date-Time-Settings.extension
40com.apple.preference.displayscom.apple.Displays-Settings.extension
41com.apple.preference.universalaccess&anchorId=Hearingcom.apple.Accessibility-Settings.extension?Hearing
42com.apple.preference.screentime&anchorId=DailyPickupscom.apple.Screen-Time-Settings.extension?path=pickups
43com.apple.preferences.ClassKitPreferencePanecom.apple.ClassKit-Settings.extension
44com.apple.preference.mousecom.apple.Mouse-Settings.extension
45com.apple.preferences.EnergySaverPrefPanecom.apple.Battery-Settings.extension
46com.apple.preferences.internetaccountscom.apple.Internet-Accounts-Settings.extension
47com.apple.preference.screentime&anchorId=CommunicationLimitcom.apple.Screen-Time-Settings.extension?path=communication-limits
48com.apple.preferences.sharingcom.apple.Sharing-Settings.extension
49com.apple.preference.universalaccess&anchorId=Captioningcom.apple.Accessibility-Settings.extension?Captioning
50com.apple.preference.universalaccess&anchorId=Dictationcom.apple.Accessibility-Settings.extension?Dictation
51com.apple.preference.printfaxcom.apple.Print-Scan-Settings.extension
52com.apple.preference.generalcom.apple.Appearance-Settings.extension
53com.apple.preference.screentime&anchorId=DailyNotificationscom.apple.Screen-Time-Settings.extension?path=notifications
54com.apple.preference.soundcom.apple.Sound-Settings.extension
55com.apple.preferences.userscom.apple.Users-Groups-Settings.extension
56com.apple.preference.universalaccess&anchorId=Keyboardcom.apple.Accessibility-Settings.extension?Keyboard
57com.apple.Passwordscom.apple.Passwords-Settings.extension
合計57項目

|

システム設定をオープンさせるスクリプトの作成補助v3


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#システム設定オープン用のスクリプト作成補助 v3
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set strBundleID to "com.apple.systempreferences" as text


############################
###【1】システム設定の起動を確定させる
set ocidRunAppArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
if (count of ocidRunAppArray) ≠ 0 then
  log "起動中です"
  tell application id strBundleID to activate
else
  ####ゾンビ対策終了させてから処理させる
  tell application id strBundleID
    set numCntWindow to (count of every window) as integer
  end tell
  if numCntWindow = 0 then
    tell application id strBundleID to quit
  else
    tell application id strBundleID
      close (every window)
      quit
    end tell
  end if
  ####半ゾンビ化対策
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
  ###システム設定を起動させる
  try
    tell application id strBundleID to activate
  on error
    tell application "System Settings" to activate
  end try
  ###起動待ち
  tell application id strBundleID
    ###起動確認 最大10秒
    repeat 10 times
      activate
      set boolFrontMost to frontmost as boolean
      log boolFrontMost
      if boolFrontMost is true then
###魔法の1秒
delay 0.5
exit repeat
      else
delay 0.5
      end if
    end repeat
  end tell
end if
############################
###【2】全てのパネルのIDを取得
tell application id "com.apple.systempreferences"
  set listPanelID to (id of every pane) as list
end tell

############################
###【A】正順レコード
set ocidPaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【B】逆順レコード
set ocidReversePaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【3】1で取得したリストの数だけ繰り返し
repeat with itemPanelID in listPanelID
  set strPanelID to itemPanelID as text
  tell application "System Settings"
    set strPanelName to (name of pane id strPanelID) as text
  end tell
  ###【A】正順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelName) forKey:(strPanelID))
(ocidPaneDict's addEntriesFromDictionary:(ocidItemDict))
  ###【B】逆順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelID) forKey:(strPanelName))
(ocidReversePaneDict's addEntriesFromDictionary:(ocidItemDict))
end repeat

############################
###【4】ダイアログ用に正順レコードのLISTを作る
set ocidAllValueArray to ocidPaneDict's allValues()
##ソートしておく
set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("self") ascending:(true) selector:("localizedStandardCompare:")
set ocidDescriptorArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidDescriptorArray's addObject:(ocidDescriptor)
set ocidSortedKey to (ocidAllValueArray's sortedArrayUsingDescriptors:(ocidDescriptorArray))
set listAllValueArray to ocidSortedKey as list
############################
###【5】ダイアログ  パネル
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listAllValueArray with title "選んでください" with prompt "選択したパネルを開きます" default items (item 1 of listAllValueArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strResponse to (item 1 of listResponse) as text
end if
log strResponse
############################
###【6】戻り値を逆順リストで検索してパネルIDを取得
set ocidPaneID to ocidReversePaneDict's valueForKey:(strResponse)
set strPaneID to ocidPaneID as text
log "strPaneID" & strPaneID
############################
###【7】アンカーの値の取得
tell application "System Settings"
  set listPaneAnchor to (name of anchors of pane strResponse) as list
  log listPaneAnchor
end tell
###【7−1】一般選択時のみアンカーが無い
if strResponse is "一般" then
  set listPaneAnchor to {"Main"} as list
end if
############################
###【8】ダイアログ アンカー
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listPaneAnchor with title "選んでください" with prompt "選択したアンカーを開きます" default items (item 1 of listPaneAnchor) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strPaneAnchor to (item 1 of listResponse) as text
end if
log strPaneAnchor


############################
###【9】URLにする
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム
ocidURLComponents's setScheme:("x-apple.systempreferences")
###パネルIDをパスにセット
ocidURLComponents's setPath:(ocidPaneID)
###アンカーをクエリーとして追加
ocidURLComponents's setQuery:(strPaneAnchor)
set ocidOpenAppURL to ocidURLComponents's |URL|
set strOpenAppURL to ocidOpenAppURL's absoluteString() as text
log strOpenAppURL

############################
###【10】ワークスペースで開く
###ファイルURLとパネルのURLをArrayにしておく
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidOpenUrlArray's insertObject:(ocidOpenAppURL) atIndex:0
###FinderでURLを開くのでFinderのURLを用意
set strBundleID to "com.apple.finder" as text
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
###NSWorkspaceで開く
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
ocidOpenConfig's setAllowsRunningApplicationSubstitution:(refMe's NSNumber's numberWithBool:true)
appShardWorkspace's openURLs:(ocidOpenUrlArray) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)

####システム設定が前面に来るまで待つ
repeat 20 times
  set boolFrontMost to frontmost of application id "com.apple.systempreferences"
  if boolFrontMost is false then
    tell application id "com.apple.systempreferences" to activate
  else
    exit repeat
  end if
  delay 0.2
end repeat


#################################
###【11】ダイアログ用に値を用意
set strScript to ("#!/usr/bin/env osascript\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\n#com.cocolog-nifty.quicktimer.icefloe\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\nuse AppleScript version \"2.8\"\nuse framework \"Foundation\"\nuse framework \"AppKit\"\nuse framework \"UniformTypeIdentifiers\"\nuse scripting additions\nproperty refMe : a reference to current application\nset strBundleID to \"com.apple.systempreferences\" as text\n###URLにする\nset ocidURLComponents to refMe's NSURLComponents's alloc()'s init()\n###スキーム\nocidURLComponents's setScheme:(\"x-apple.systempreferences\")\n###パネルIDをパスにセット\nocidURLComponents's setPath:(\"" & strPaneID & "\")\n###アンカーをクエリーとして追加\nocidURLComponents's setQuery:(\"" & strPaneAnchor & "\")\nset ocidOpenAppURL to ocidURLComponents's |URL|\nset strOpenAppURL to ocidOpenAppURL's absoluteString() as text\n###ワークスペースで開く\nset appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()\nset boolDone to appShardWorkspace's openURL:(ocidOpenAppURL)\nlog boolDone\nif boolDone is false then\ntell application id \"com.apple.systempreferences\" to activate\ntell application id \"com.apple.systempreferences\"\nreveal anchor \"" & strPaneAnchor & "\" of pane id \"" & strPaneID & "\"\nend tell\ntell application id \"com.apple.finder\"\nopen location \"" & strOpenAppURL & "\"\nend tell\ntell application id \"com.apple.systempreferences\" to activate\nend if\nreturn\n")

#################################
###【12】戻り値ダイアログ
set strName to (name of current application) as text
log strName
if strName is "osascript" then
  repeat 20 times
    set boolFrontMost to frontmost of application "Finder"
    if boolFrontMost is false then
      tell application "Finder" to activate
    else
      exit repeat
    end if
    delay 0.2
  end repeat
else
  repeat 5 times
    set boolFrontMost to frontmost of application "Script Editor"
    log boolFrontMost
    if boolFrontMost is false then
      tell current application to activate
    else
      exit repeat
    end if
    delay 0.2
  end repeat
  
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/ManagedClient.app/Contents/PlugIns/ConfigurationProfilesUI.bundle/Contents/Resources/SystemPrefApp.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "スクリプト戻り値です" with title "【3】スクリプト" default answer strScript buttons {"クリップボードにコピー", "キャンセル", "スクリプトエディタで開く"} default button "スクリプトエディタで開く" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)
#################################
###【13】クリップボードにコピー
if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if
#################################
###【14】OK押したらスクリプト生成
if button returned of recordResult is "スクリプトエディタで開く" then
  ##ファイル名
  set strFileName to (strResponse & "." & (ocidPaneID as text) & "." & strPaneAnchor & ".applescript") as text
  ##保存先はスクリプトメニュー
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidLibraryDIrURL to ocidURLsArray's firstObject()
  set ocidScriptDirPathURL to ocidLibraryDIrURL's URLByAppendingPathComponent:("Scripts/Applications/System Settings/Open")
  ###フォルダを作って
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidScriptDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  set ocidSaveFilePathURL to ocidScriptDirPathURL's URLByAppendingPathComponent:(strFileName)
  ###スクリプトをテキストで保存
  set ocidScript to refMe's NSString's stringWithString:(strScript)
  ##改行はLFで
  set ocidLFScript to ocidScript's stringByReplacingOccurrencesOfString:("\r") withString:("\n")
  # set ocidEnc to (refMe's NSUTF16LittleEndianStringEncoding)
  # ターミナルからの実行を配慮してUTF8に
  set ocidEnc to (refMe's NSUTF8StringEncoding)
  set listDone to ocidLFScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(ocidEnc) |error|:(reference)
  delay 0.5
  set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
  ###ターミナルから実行できるように755に
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidSaveFilePathURL's |path|()) |error|:(reference)
  
  
  ###保存したスクリプトを開く
  tell application "Script Editor"
    open aliasSaveFilePath
  end tell
end if



|

com.apple.Network-Link-Conditioner

com.apple.Network-Link-Conditionerパネルのオープンは

set strCommandText to "/usr/bin/open '/Library/PreferencePanes/Network Link Conditioner.prefPane'" as text
do shell script strCommandText
-->パス指定が現在は安定感がある
tell application id "com.apple.finder"
  open location "x-apple.systempreferences:com.apple.Network-Link-Conditioner"
end tell

tell application id "com.apple.systempreferences"
reveal anchor "Network Link Conditioner" of pane id "com.apple.Network-Link-Conditioner"
end tell
-->error "System Settingsでエラーが起きました: anchor \"Network Link Conditioner\" of pane id \"com.apple.Network-Link-Conditioner\"を取り出すことはできません。" number -1728 from anchor "Network Link Conditioner" of pane id "com.apple.Network-Link-Conditioner"

set strCommandText to "/usr/bin/open -b com.apple.Network-Link-Conditioner" as text
do shell script strCommandText
-->error "LSCopyApplicationURLsForBundleIdentifier() failed while trying to determine the application with bundle identifier com.apple.Network-Link-Conditioner." number 1

|

[macos14]システム設定収集 macOS14対応版


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#システム設定オープン用のスクリプト作成補助 v3
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set strBundleID to "com.apple.systempreferences" as text


############################
###【1】システム設定の起動を確定させる
set ocidRunAppArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
if (count of ocidRunAppArray) ≠ 0 then
  log "起動中です"
  tell application id strBundleID to activate
else
  ####ゾンビ対策終了させてから処理させる
  tell application id strBundleID
    set numCntWindow to (count of every window) as integer
  end tell
  if numCntWindow = 0 then
    tell application id strBundleID to quit
  else
    tell application id strBundleID
      close (every window)
      quit
    end tell
  end if
  ####半ゾンビ化対策
  set ocidRunningApplication to refMe's NSRunningApplication
  set ocidAppArray to ocidRunningApplication's runningApplicationsWithBundleIdentifier:(strBundleID)
  repeat with itemAppArray in ocidAppArray
itemAppArray's terminate
  end repeat
  ###システム設定を起動させる
  try
    tell application id strBundleID to activate
  on error
    tell application "System Settings" to activate
  end try
  ###起動待ち
  tell application id strBundleID
    ###起動確認 最大10秒
    repeat 10 times
      activate
      set boolFrontMost to frontmost as boolean
      log boolFrontMost
      if boolFrontMost is true then
###魔法の1秒
delay 0.5
exit repeat
      else
delay 0.5
      end if
    end repeat
  end tell
end if
############################
###【2】全てのパネルのIDを取得
tell application id "com.apple.systempreferences"
  set listPanelID to (id of every pane) as list
end tell

############################
###【A】正順レコード
set ocidPaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【B】逆順レコード
set ocidReversePaneDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###【3】1で取得したリストの数だけ繰り返し
repeat with itemPanelID in listPanelID
  set strPanelID to itemPanelID as text
  tell application "System Settings"
    set strPanelName to (name of pane id strPanelID) as text
  end tell
  ###【A】正順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelName) forKey:(strPanelID))
(ocidPaneDict's addEntriesFromDictionary:(ocidItemDict))
  ###【B】逆順レコード
  set ocidItemDict to (refMe's NSDictionary's dictionaryWithObject:(strPanelID) forKey:(strPanelName))
(ocidReversePaneDict's addEntriesFromDictionary:(ocidItemDict))
end repeat

############################
###【4】ダイアログ用に正順レコードのLISTを作る
set ocidAllValueArray to ocidPaneDict's allValues()
##ソートしておく
set ocidDescriptor to refMe's NSSortDescriptor's sortDescriptorWithKey:("self") ascending:(true) selector:("localizedStandardCompare:")
set ocidDescriptorArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
ocidDescriptorArray's addObject:(ocidDescriptor)
set ocidSortedKey to (ocidAllValueArray's sortedArrayUsingDescriptors:(ocidDescriptorArray))
set listAllValueArray to ocidSortedKey as list
############################
###【5】ダイアログ  パネル
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listAllValueArray with title "選んでください" with prompt "選択したパネルを開きます" default items (item 1 of listAllValueArray) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strResponse to (item 1 of listResponse) as text
end if
log strResponse
############################
###【6】戻り値を逆順リストで検索してパネルIDを取得
set ocidPaneID to ocidReversePaneDict's valueForKey:(strResponse)
set strPaneID to ocidPaneID as text

############################
###【7】アンカーの値の取得
tell application "System Settings"
  set listPaneAnchor to (name of anchors of pane strResponse) as list
  log listPaneAnchor
end tell
############################
###【8】ダイアログ アンカー
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
try
  set listResponse to (choose from list listPaneAnchor with title "選んでください" with prompt "選択したアンカーを開きます" default items (item 1 of listPaneAnchor) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
else
  set strPaneAnchor to (item 1 of listResponse) as text
end if
log strPaneAnchor


############################
###【9】URLにする
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
###スキーム
ocidURLComponents's setScheme:("x-apple.systempreferences")
###パネルIDをパスにセット
ocidURLComponents's setPath:(ocidPaneID)
###アンカーをクエリーとして追加
ocidURLComponents's setQuery:(strPaneAnchor)
set ocidOpenAppURL to ocidURLComponents's |URL|
set strOpenAppURL to ocidOpenAppURL's absoluteString() as text
log strOpenAppURL

############################
###【10】ワークスペースで開く
###ファイルURLとパネルのURLをArrayにしておく
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
ocidOpenUrlArray's insertObject:(ocidOpenAppURL) atIndex:0
###FinderでURLを開くのでFinderのURLを用意
set strBundleID to "com.apple.finder" as text
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
###NSWorkspaceで開く
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration()
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
ocidOpenConfig's setAllowsRunningApplicationSubstitution:(refMe's NSNumber's numberWithBool:true)
appShardWorkspace's openURLs:(ocidOpenUrlArray) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)

####システム設定が前面に来るまで待つ
repeat 20 times
  set boolFrontMost to frontmost of application id "com.apple.systempreferences"
  if boolFrontMost is false then
    tell application id "com.apple.systempreferences" to activate
  else
    exit repeat
  end if
  delay 0.2
end repeat


#################################
###【11】ダイアログ用に値を用意
set strScript to ("#!/usr/bin/env osascript\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\n#com.cocolog-nifty.quicktimer.icefloe\n----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\nuse AppleScript version \"2.8\"\nuse framework \"Foundation\"\nuse framework \"AppKit\"\nuse framework \"UniformTypeIdentifiers\"\nuse scripting additions\nproperty refMe : a reference to current application\nset strBundleID to \"com.apple.systempreferences\" as text\n###URLにする\nset ocidURLComponents to refMe's NSURLComponents's alloc()'s init()\n###スキーム\nocidURLComponents's setScheme:(\"x-apple.systempreferences\")\n###パネルIDをパスにセット\nocidURLComponents's setPath:(\"" & strPaneID & "\")\n###アンカーをクエリーとして追加\nocidURLComponents's setQuery:(\"" & strPaneAnchor & "\")\nset ocidOpenAppURL to ocidURLComponents's |URL|\nset strOpenAppURL to ocidOpenAppURL's absoluteString() as text\n###ワークスペースで開く\nset appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()\nset boolDone to appShardWorkspace's openURL:(ocidOpenAppURL)\nlog boolDone\nif boolDone is false then\ntell application id \"com.apple.systempreferences\" to activate\ntell application id \"com.apple.systempreferences\"\nreveal anchor \"" & strPaneAnchor & "\" of pane id \"" & strPaneID & "\"\nend tell\ntell application id \"com.apple.finder\"\nopen location \"" & strOpenAppURL & "\"\nend tell\ntell application id \"com.apple.systempreferences\" to activate\nend if\nreturn\n")

#################################
###【12】戻り値ダイアログ
set strName to (name of current application) as text
log strName
if strName is "osascript" then
  repeat 20 times
    set boolFrontMost to frontmost of application "Finder"
    if boolFrontMost is false then
      tell application "Finder" to activate
    else
      exit repeat
    end if
    delay 0.2
  end repeat
else
  repeat 5 times
    set boolFrontMost to frontmost of application "Script Editor"
    log boolFrontMost
    if boolFrontMost is false then
      tell current application to activate
    else
      exit repeat
    end if
    delay 0.2
  end repeat
  
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/ManagedClient.app/Contents/PlugIns/ConfigurationProfilesUI.bundle/Contents/Resources/SystemPrefApp.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "スクリプト戻り値です" with title "【3】スクリプト" default answer strScript buttons {"クリップボードにコピー", "キャンセル", "スクリプトエディタで開く"} default button "スクリプトエディタで開く" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)
#################################
###【13】クリップボードにコピー
if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if
#################################
###【14】OK押したらスクリプト生成
if button returned of recordResult is "スクリプトエディタで開く" then
  ##ファイル名
  set strFileName to (strResponse & "." & (ocidPaneID as text) & "." & strPaneAnchor & ".applescript") as text
  ##保存先はスクリプトメニュー
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidLibraryDIrURL to ocidURLsArray's firstObject()
  set ocidScriptDirPathURL to ocidLibraryDIrURL's URLByAppendingPathComponent:("Scripts/Applications/System Settings/Open")
  ###フォルダを作って
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidScriptDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  set ocidSaveFilePathURL to ocidScriptDirPathURL's URLByAppendingPathComponent:(strFileName)
  ###スクリプトをテキストで保存
  set ocidScript to refMe's NSString's stringWithString:(strScript)
  ##改行はLFで
  set ocidLFScript to ocidScript's stringByReplacingOccurrencesOfString:("\r") withString:("\n")
  # set ocidEnc to (refMe's NSUTF16LittleEndianStringEncoding)
  # ターミナルからの実行を配慮してUTF8に
  set ocidEnc to (refMe's NSUTF8StringEncoding)
  set listDone to ocidLFScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(ocidEnc) |error|:(reference)
  delay 0.5
  set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
  ###ターミナルから実行できるように755に
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listDone to appFileManager's setAttributes:(ocidAttrDict) ofItemAtPath:(ocidSaveFilePathURL's |path|()) |error|:(reference)
  
  
  ###保存したスクリプトを開く
  tell application "Script Editor"
    open aliasSaveFilePath
  end tell
end if



|

[com.apple.systempreferences]システム設定情報収集v2(ファイルを保存するように変更)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

###起動
tell application id "com.apple.systempreferences"
  launch
end tell
###起動待ち
tell application id "com.apple.systempreferences"
  ###起動確認 最大10秒
  repeat 10 times
    activate
    set boolFrontMost to frontmost as boolean
    if boolFrontMost is true then
      exit repeat
    else
      delay 1
    end if
  end repeat
end tell
###パネルの名前を取得
tell application id "com.apple.systempreferences"
  set listPaneName to name of every pane as list
end tell
if (count of listPaneName) = 0 then
  ###起動待ち
  tell application id "com.apple.systempreferences"
    ###起動確認 最大10秒
    repeat 10 times
      set listPaneName to name of every pane as list
      
      if (count of listPaneName) ≠ 0 then
exit repeat
      else
delay 1
      end if
    end repeat
  end tell
end if
-->だいたいの戻り値(参考)
{"外観", "プリンタとスキャナ", "インターネットアカウント", "集中モード", "スクリーンセーバ", "ウォレットとApple Pay", "SiriとSpotlight", "キーボード", "デスクトップとDock", "アクセシビリティ", "壁紙", "プライバシーとセキュリティ", "機能拡張", "プロファイル", "スクリーンタイム", "Bluetooth", "AppleIDの名前", "ユーザとグループ", "ロック画面", "ディスプレイ", "Wi‑Fi", "トラックパッド", "バッテリー", "コントロールセンター", "マウス", "パスワード", "通知", "ネットワーク", "一般", "情報", "ソフトウェアアップデート", "ストレージ", "AirDropとHandoff", "ログイン項目", "言語と地域", "日付と時刻", "共有", "Time Machine", "転送またはリセット", "起動ディスク", "Touch IDとパスコード", "サウンド", "ファミリー", "Game Center", "Network Link Conditioner"}


tell current application
  activate
end tell
try
  set listResponse to (choose from list listPaneName with title "選んでください" with prompt "選んでください" default items (item 1 of listPaneName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
end if



--> {"情報"}
set strPaneName to item 1 of listResponse as text
####ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

if strPaneName is "一般" then
  set listPaneName to {"情報", "ソフトウェアアップデート", "ストレージ", "AirDropとHandoff", "ログイン項目", "言語と地域", "日付と時刻", "共有", "Time Machine", "転送またはリセット", "起動ディスク"} as list
  try
    set listResponse to (choose from list listPaneName with title "選んでください" with prompt "パネルを選んでください" default items (item 1 of listPaneName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
  if (item 1 of listResponse) is false then
return "キャンセルしました"
  end if
  
  set strPaneName to item 1 of listResponse as text
end if


###選んだパネルのIDを取得
tell application id "com.apple.systempreferences"
  set strPaneId to id of pane strPaneName
end tell
###アンカーの値の取得
tell application id "com.apple.systempreferences"
  set listPaneAnchor to (name of anchors of pane strPaneName) as list
  log listPaneAnchor
  --> (*aboutSection, displaysSection, generalSection, legalSection, softwareSection, storageSection*)
end tell

try
  ####ダイアログを前面に
  tell current application
    set strName to name as text
  end tell
  if strName is "osascript" then
    tell application "Finder" to activate
  else
    tell current application to activate
  end if
  set listAnchorName to (choose from list listPaneAnchor with title "選んでください" with prompt "パネルを選んでください" default items (item 1 of listPaneAnchor) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listAnchorName) is false then
return "キャンセルしました"
end if
set strAnchorName to item 1 of listAnchorName as text

###選んだアンカーで開く
tell application id "com.apple.systempreferences"
  launch
  activate
reveal anchor strAnchorName of pane id strPaneId
end tell

###コピー用のスクリプトテキスト
set strScript to "#!/usr/bin/env osascript\r----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\r#com.cocolog-nifty.quicktimer.icefloe\r#" & strAnchorName & ":" & strPaneId & "\r----+----1----+----2----+-----3----+----4----+----5----+----6----+----7\ruse AppleScript version \"2.8\"\ruse scripting additions\rtell application id \"com.apple.systempreferences\"\r\tlaunch\r\tactivate\r\treveal anchor \"" & strAnchorName & "\" of pane id \"" & strPaneId & "\"\rend tell\rtell application id \"com.apple.finder\"\r\topen location \"x-apple.systempreferences:" & strPaneId & "?" & strAnchorName & "\"\rend tell\r"

####ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "スクリプト戻り値です" with title "スクリプト" default answer strScript buttons {"クリップボードにコピー", "キャンセル", "スクリプトエディタで開く"} default button "スクリプトエディタで開く" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if
###OK押したらスクリプト生成
if button returned of recordResult is "スクリプトエディタで開く" then
  set strFileName to (strAnchorName & "." & strPaneId & ".applescript") as text
  
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidLibraryDIrURL to ocidURLsArray's firstObject()
  set ocidScriptDirPathURL to ocidLibraryDIrURL's URLByAppendingPathComponent:("Scripts/Applications/System Settings/Open")
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidScriptDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
  set ocidSaveFilePathURL to ocidScriptDirPathURL's URLByAppendingPathComponent:(strFileName)
  set ocidScript to refMe's NSString's stringWithString:(strScript)
  set listDone to ocidScript's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF16LittleEndianStringEncoding) |error|:(reference)
  delay 0.5
  set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
  
  tell application "Script Editor"
    open aliasSaveFilePath
  end tell
end if



|

[com.apple.helpviewer]x-help-action://openPrefPane?bundleId=

Plist情報:prefsmapping.plist.html
項番キーの名前キーの値
1com.apple.preferences.walletcom.apple.WalletSettingsExtension
2com.apple.preference.universalaccess&anchorId=Accessibility_Shortcutcom.apple.Accessibility-Settings.extension?Accessibility_Shortcut
3com.apple.preference.universalaccess&anchorId=Siricom.apple.Accessibility-Settings.extension?Siri
4com.apple.preference.universalaccess&anchorId=TextToSpeechcom.apple.Accessibility-Settings.extension?TextToSpeech
5com.apple.preference.universalaccess&anchorId=Seeing_Zoomcom.apple.Accessibility-Settings.extension?Seeing_Zoom
6com.apple.preference.trackpadcom.apple.Trackpad-Settings.extension
7com.apple.preference.universalaccess&anchorId=Seeing_VoiceOvercom.apple.Accessibility-Settings.extension?Seeing_VoiceOver
8com.apple.preference.securitycom.apple.settings.PrivacySecurity.extension
9com.apple.preference.screentimecom.apple.Screen-Time-Settings.extension
10com.apple.preferences.FamilySharingPrefPanecom.apple.Family-Settings.extension*Family
11com.apple.preference.universalaccess&anchorId=Media_Descriptionscom.apple.Accessibility-Settings.extension?Media_Descriptions
12com.apple.preference.universalaccesscom.apple.Accessibility-Settings.extension
13com.apple.preference.screentime&anchorId=Downtimecom.apple.Screen-Time-Settings.extension?path=downtime
14com.apple.preferences.Bluetoothcom.apple.BluetoothSettings
15com.apple.preferences.softwareupdatecom.apple.Software-Update-Settings.extension
16com.apple.preference.desktopscreeneffectcom.apple.Wallpaper-Settings.extension
17com.apple.prefs.backupcom.apple.Time-Machine-Settings.extension
18com.apple.preference.batterycom.apple.Battery-Settings.extension*BatteryPreferences
19com.apple.preference.networkcom.apple.Network-Settings.extension
20com.apple.preference.screentime&anchorId=AlwaysAllowedcom.apple.Screen-Time-Settings.extension?path=always-allowed
21com.apple.preferences.configurationprofilescom.apple.Profiles-Settings.extension
22com.apple.preference.screentime&anchorId=DailyUsagecom.apple.Screen-Time-Settings.extension?path=app-usage
23com.apple.preference.universalaccess&anchorId=Mousecom.apple.Accessibility-Settings.extension?Mouse
24com.apple.preferences.AppleIDPrefPanecom.apple.systempreferences.AppleIDSettings*AppleIDSettings
25com.apple.preferences.extensionscom.apple.ExtensionsPreferences
26com.apple.preference.notificationscom.apple.Notifications-Settings.extension
27com.apple.preference.keyboardcom.apple.Keyboard-Settings.extension
28com.apple.preference.dockcom.apple.Desktop-Settings.extension
29com.apple.preference.screentime&anchorId=ViewUsageLimitcom.apple.Screen-Time-Settings.extension?path=app-limits
30com.apple.preference.screentime&anchorId=ContentAndPrivacycom.apple.Screen-Time-Settings.extension?path=content-and-privacy
31com.apple.preference.spotlightcom.apple.Siri-Settings.extension
32com.apple.preference.digihub.discscom.apple.CD-DVD-Settings.extension
33com.apple.preference.universalaccess&anchorId=Switchcom.apple.Accessibility-Settings.extension?Switch
34com.apple.preferences.passwordcom.apple.Touch-ID-Settings.extension*TouchIDPasswordPrefs
35com.apple.Localizationcom.apple.Localization-Settings.extension
36com.apple.preference.universalaccess&anchorId=Seeing_Displaycom.apple.Accessibility-Settings.extension?Seeing_Display
37com.apple.preference.startupdiskcom.apple.Startup-Disk-Settings.extension
38com.apple.preference.speechcom.apple.Siri-Settings.extension
39com.apple.preference.datetimecom.apple.Date-Time-Settings.extension
40com.apple.preference.displayscom.apple.Displays-Settings.extension
41com.apple.preference.universalaccess&anchorId=Hearingcom.apple.Accessibility-Settings.extension?Hearing
42com.apple.preference.screentime&anchorId=DailyPickupscom.apple.Screen-Time-Settings.extension?path=pickups
43com.apple.preferences.ClassKitPreferencePanecom.apple.ClassKit-Settings.extension
44com.apple.preference.mousecom.apple.Mouse-Settings.extension
45com.apple.preferences.EnergySaverPrefPanecom.apple.Battery-Settings.extension
46com.apple.preferences.internetaccountscom.apple.Internet-Accounts-Settings.extension
47com.apple.preference.screentime&anchorId=CommunicationLimitcom.apple.Screen-Time-Settings.extension?path=communication-limits
48com.apple.preferences.sharingcom.apple.Sharing-Settings.extension
49com.apple.preference.universalaccess&anchorId=Captioningcom.apple.Accessibility-Settings.extension?Captioning
50com.apple.preference.universalaccess&anchorId=Dictationcom.apple.Accessibility-Settings.extension?Dictation
51com.apple.preference.printfaxcom.apple.Print-Scan-Settings.extension
52com.apple.preference.generalcom.apple.Appearance-Settings.extension
53com.apple.preference.screentime&anchorId=DailyNotificationscom.apple.Screen-Time-Settings.extension?path=notifications
54com.apple.preference.soundcom.apple.Sound-Settings.extension
55com.apple.preferences.userscom.apple.Users-Groups-Settings.extension
56com.apple.preference.universalaccess&anchorId=Keyboardcom.apple.Accessibility-Settings.extension?Keyboard
57com.apple.Passwordscom.apple.Passwords-Settings.extension
合計57項目

|

システム設定を開く(不具合修正)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

###起動
tell application id "com.apple.systempreferences"
  launch
end tell
###起動待ち
tell application id "com.apple.systempreferences"
  ###起動確認 最大10秒
  repeat 10 times
    activate
    set boolFrontMost to frontmost as boolean
    if boolFrontMost is true then
      exit repeat
    else
      delay 1
    end if
  end repeat
end tell
###パネルの名前を取得
tell application id "com.apple.systempreferences"
  set listPaneName to name of every pane as list
end tell
if (count of listPaneName) = 0 then
  ###起動待ち
  tell application id "com.apple.systempreferences"
    ###起動確認 最大10秒
    repeat 10 times
      set listPaneName to name of every pane as list
      
      if (count of listPaneName) ≠ 0 then
exit repeat
      else
delay 1
      end if
    end repeat
  end tell
end if
-->だいたいの戻り値(参考)
{"外観", "プリンタとスキャナ", "インターネットアカウント", "集中モード", "スクリーンセーバ", "ウォレットとApple Pay", "SiriとSpotlight", "キーボード", "デスクトップとDock", "アクセシビリティ", "壁紙", "プライバシーとセキュリティ", "機能拡張", "プロファイル", "スクリーンタイム", "Bluetooth", "AppleIDの名前", "ユーザとグループ", "ロック画面", "ディスプレイ", "Wi‑Fi", "トラックパッド", "バッテリー", "コントロールセンター", "マウス", "パスワード", "通知", "ネットワーク", "一般", "情報", "ソフトウェアアップデート", "ストレージ", "AirDropとHandoff", "ログイン項目", "言語と地域", "日付と時刻", "共有", "Time Machine", "転送またはリセット", "起動ディスク", "Touch IDとパスコード", "サウンド", "ファミリー", "Game Center", "Network Link Conditioner"}


tell current application
  activate
end tell
try
  set listResponse to (choose from list listPaneName with title "選んでください" with prompt "選んでください" default items (item 1 of listPaneName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listResponse) is false then
return "キャンセルしました"
end if



--> {"情報"}
set strPaneName to item 1 of listResponse as text
####ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if

if strPaneName is "一般" then
  set listPaneName to {"情報", "ソフトウェアアップデート", "ストレージ", "AirDropとHandoff", "ログイン項目", "言語と地域", "日付と時刻", "共有", "Time Machine", "転送またはリセット", "起動ディスク"} as list
  try
    set listResponse to (choose from list listPaneName with title "選んでください" with prompt "パネルを選んでください" default items (item 1 of listPaneName) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
  if (item 1 of listResponse) is false then
return "キャンセルしました"
  end if
  
  set strPaneName to item 1 of listResponse as text
end if


###選んだパネルのIDを取得
tell application id "com.apple.systempreferences"
  set strPaneId to id of pane strPaneName
end tell
###アンカーの値の取得
tell application id "com.apple.systempreferences"
  set listPaneAnchor to (name of anchors of pane strPaneName) as list
  log listPaneAnchor
  --> (*aboutSection, displaysSection, generalSection, legalSection, softwareSection, storageSection*)
end tell

try
  ####ダイアログを前面に
  tell current application
    set strName to name as text
  end tell
  if strName is "osascript" then
    tell application "Finder" to activate
  else
    tell current application to activate
  end if
  set listAnchorName to (choose from list listPaneAnchor with title "選んでください" with prompt "パネルを選んでください" default items (item 1 of listPaneAnchor) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
on error
  log "エラーしました"
return "エラーしました"
end try
if (item 1 of listAnchorName) is false then
return "キャンセルしました"
end if
set strAnchorName to item 1 of listAnchorName as text

###選んだアンカーで開く
tell application id "com.apple.systempreferences"
  launch
  activate
reveal anchor strAnchorName of pane id strPaneId
end tell

###コピー用のスクリプトテキスト
set strScript to "tell application id \"com.apple.systempreferences\"\r\tlaunch\r\tactivate\r\treveal anchor \"" & strAnchorName & "\" of pane id \"" & strPaneId & "\"\rend tell"

####ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###ダイアログ
set strIconPath to "/System/Library/CoreServices/Finder.app/Contents/Resources/Finder.icns"
set aliasIconPath to POSIX file strIconPath as alias
set recordResult to (display dialog "スクリプト戻り値です" with title "スクリプト" default answer strScript buttons {"クリップボードにコピー", "キャンセル", "スクリプトエディタで開く"} default button "スクリプトエディタで開く" giving up after 20 with icon aliasIconPath without hidden answer)

if button returned of recordResult is "クリップボードにコピー" then
  set strText to text returned of recordResult as text
  ####ペーストボード宣言
  set appPasteboard to refMe's NSPasteboard's generalPasteboard()
  set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
end if
###OK押したらスクリプト生成
if button returned of recordResult is "スクリプトエディタで開く" then
  set ocidChrSet to refMe's NSCharacterSet's URLQueryAllowedCharacterSet
  set ocidEncodedText to refMe's NSMutableString's alloc()'s initWithCapacity:0
  set ocidScript to refMe's NSString's stringWithString:(strScript)
ocidEncodedText's setString:(ocidScript)
  ######## 置換 %エンコードの追加処理
  ###置換レコード
  set recordPercentMap to {|+|:"%2B", |=|:"%3D", |&|:"%26", |$|:"%24"} as record
  ###ディクショナリにして
  set ocidPercentMap to refMe's NSDictionary's alloc()'s initWithDictionary:recordPercentMap
  ###キーの一覧を取り出します
  set ocidAllKeys to ocidPercentMap's allKeys()
  
  ###取り出したキー一覧を順番に処理
  repeat with itemAllKey in ocidAllKeys
    ##キーの値を取り出して
    set ocidMapValue to (ocidPercentMap's valueForKey:itemAllKey)
    ##置換
    set ocidEncodedText to (ocidEncodedText's stringByReplacingOccurrencesOfString:(itemAllKey) withString:(ocidMapValue))
    ##次の変換に備える
    set ocidTextToEncode to ocidEncodedText
  end repeat
  ###URLになるのでロケーションとしてOPENする
  set strEncodedText to ocidTextToEncode as text
  set strURL to "applescript://com.apple.scripteditor?action=new&name=" & strPaneId & "&script=" & strEncodedText & ""
  tell application "Finder"
    open location strURL
  end tell
end if



|

システム設定のパネルを指定して開く(改良)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "UniformTypeIdentifiers"
use scripting additions

property refMe : a reference to current application

set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()

###システム設定のバンドルID
set strBundleID to "com.apple.systempreferences" as text
###システム設定のNSBundle
set ocidAppBundle to refMe's NSBundle's bundleWithIdentifier:(strBundleID)
if ocidAppBundle is not (missing value) then
  ###URLを取得
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else
  ###URLを取得
  set ocidAppPathURL to appShardWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID)
end if
##ワークスペースに渡すURLのリスト
set ocidOpenUrlArray to refMe's NSMutableArray's alloc()'s initWithCapacity:0
##com.apple.preferences.configurationprofilesのURL
set ocidURLComponents to refMe's NSURLComponents's alloc()'s init()
ocidURLComponents's setScheme:("x-apple.systempreferences")
ocidURLComponents's setPath:("com.apple.preferences.configurationprofiles")
set ocidOpenURL to ocidURLComponents's |URL|
set strPanelURL to (ocidOpenURL's absoluteString()) as text
##URLリストに追加
ocidOpenUrlArray's insertObject:(ocidOpenURL) atIndex:0
##OPENコンフィグ アクティベートのみ設定
set ocidOpenConfig to refMe's NSWorkspaceOpenConfiguration's configuration
ocidOpenConfig's setActivates:(refMe's NSNumber's numberWithBool:true)
## システム設定でプロファイルのURLを開く
##これでも良いし
appShardWorkspace's openURLs:(ocidOpenUrlArray) withApplicationAtURL:(ocidAppPathURL) configuration:(ocidOpenConfig) completionHandler:(missing value)
##こっちでも同じ
appShardWorkspace's openURL:(ocidOpenURL)


|

より以前の記事一覧

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom