【システム設定】ユーザー辞書を開く
【スクリプトエディタで開く】 |
【システム設定】ユーザー辞書を開く.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 |
| 005 | use AppleScript version "2.8" |
| 006 | use framework "Foundation" |
| 007 | use framework "AppKit" |
| 008 | use framework "UniformTypeIdentifiers" |
| 009 | use scripting additions |
| 010 | property refMe : a reference to current application |
| 011 | set strBundleID to ("com.apple.systempreferences") as text |
| 012 | ###URLにする |
| 013 | set ocidURLComponents to refMe's NSURLComponents's alloc()'s init() |
| 014 | ###スキーム |
| 015 | ocidURLComponents's setScheme:("x-apple.systempreferences") |
| 016 | ###パネルIDをパスにセット |
| 017 | ocidURLComponents's setPath:("com.apple.Keyboard-Settings.extension") |
| 018 | ###アンカーをクエリーとして追加 |
| 019 | ocidURLComponents's setQuery:("TextReplacements") |
| 020 | set ocidOpenAppURL to ocidURLComponents's |URL| |
| 021 | set strOpenAppURL to ocidOpenAppURL's absoluteString() as text |
| 022 | ###ワークスペースで開く |
| 023 | set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace() |
| 024 | set boolDone to appShardWorkspace's openURL:(ocidOpenAppURL) |
| 025 | log boolDone |
| 026 | if 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 |
| 038 | end if |
| 039 | ###開くのを待つ |
| 040 | repeat 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 |
| 051 | end repeat |
| 052 | ###パネルを確認して |
| 053 | repeat 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 |
| 065 | end repeat |
| 066 | ###アンカーを再指定 |
| 067 | tell 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 |
| 075 | end tell |
| 076 | return 0 |
| AppleScriptで生成しました |
|---|