20260526

[システム設定]CDとDVDパネルを開くOBJC

[システム設定]CDとDVDパネルを開くOBJC

NOTE記事一覧ですnote.com
 

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

CDとDVDパネルを開くOBJC.scpt.scpt
ソース
001#!/usr/bin/env osascript
002#coding: utf-8
003----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
004(*
005
006CDとDVDシステム設定パネルを開く
007
008CDとDVDのシステム設定のパネルは旧仕様
009かつ
010CDプレイヤーデバイスが接続されないと表示されない設定
011
012
013
014com.cocolog-nifty.quicktimer.icefloe *)
015----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
016use AppleScript version "2.8"
017use framework "Foundation"
018use framework "AppKit"
019use framework "UniformTypeIdentifiers"
020use scripting additions
021
022property refMe : a reference to current application
023
024set appFileManager to refMe's NSFileManager's defaultManager()
025set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSSystemDomainMask))
026set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
027set ocidTargetFilePathURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:("PreferencePanes/DigiHubDiscs.prefPane") isDirectory:(false)
028#
029set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
030set boolDone to appSharedWorkspace's openURL:(ocidTargetFilePathURL)
031set appFinderArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:("com.apple.systempreferences")
032set appFinder to appFinderArray's firstObject()
033set boolDone to appFinder's activateWithOptions:(refMe's NSApplicationActivateIgnoringOtherApps)
034#
035set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
036set ocidOpenURLsArray to refMe's NSMutableArray's alloc()'s init()
037(ocidOpenURLsArray's addObject:(ocidTargetFilePathURL))
038appSharedWorkspace's activateFileViewerSelectingURLs:(ocidOpenURLsArray)
039#
040delay 3
041set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
042set boolDone to appSharedWorkspace's openURL:(ocidTargetFilePathURL)
043set appFinderArray to refMe's NSRunningApplication's runningApplicationsWithBundleIdentifier:("com.apple.systempreferences")
044set appFinder to appFinderArray's firstObject()
045set boolDone to appFinder's activateWithOptions:(refMe's NSApplicationActivateIgnoringOtherApps)
046
047return boolDone
AppleScriptで生成しました