20260516

【システム設定】ユーザー辞書を開く

【システム設定】ユーザー辞書を開く

NOTE記事一覧ですnote.com
 

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

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