[Shortcuts]AppleScriptでショートカットの名前を取得する
1:ショートカットの名前を取得する
2:ショートカットのUUIDを取得する
3:フォルダ名を取得する
4:ショートカットを実行する
5:ショートカットのフォルダ名を取得する
ダウンロード - shortcutse382b5e383b3e38395e3829ae383ab.zip
Shortcutsの名前とIDを取得する
tell application "Script Editor"
tell application "System Events"
keystroke "l" using {command down, option down}
end tell
end tell
delay 1
tell application "Shortcuts"
set numFolderCnt to (count every folder) as number
set numChk to 1
repeat numFolderCnt times
set strFolderName to name of folder numChk
set strFolderID to id of folder numChk
log "フォルダ名:" & strFolderName
log "フォルダID:" & strFolderID
set numChk to numChk + 1
end repeat
set numShortcutsCnt to (count every shortcut) as number
set numChk to 1
repeat numShortcutsCnt times
set strShortcutName to name of shortcut numChk
set strShortcutID to id of shortcut numChk
set strShortcutFolder to folder of shortcut numChk
set strShortcutSubtitle to subtitle of shortcut numChk
log "ShortcutName :" & strShortcutName
log "ShortcutID:" & strShortcutID
set numChk to numChk + 1
end repeat
end tell
Shortcutsフォルダ毎にショートカットを取得
tell application "Script Editor"
tell application "System Events"
keystroke "l" using {command down, option down}
end tell
end tell
delay 1
tell application "Shortcuts"
set numFolderCnt to (count every folder) as number
set numChk to 1
repeat numFolderCnt times
set strFolderName to name of folder numChk
set strFolderID to id of folder numChk
log "フォルダ名:" & strFolderName
log "フォルダID:" & strFolderID
tell folder id strFolderID
set numShortcutsCnt to (count shortcut) as number
set numSChk to 1
repeat numShortcutsCnt times
set strShortcutName to name of shortcut numSChk
set strShortcutID to id of shortcut numSChk
set strShortcutFolder to folder of shortcut numSChk
set strShortcutSubtitle to subtitle of shortcut numSChk
log "" & strFolderName & ":ShortcutName :" & strShortcutName
log "" & strFolderName & ":ShortcutID:" & strShortcutID
log "" & strFolderName & ":ShortcutSubtitle:" & strShortcutSubtitle
set numSChk to numSChk + 1
end repeat
end tell
log "---------------------------------------------------"
set numChk to numChk + 1
end repeat
end tell
Shortcuts実行
→これはサンプル実際には自分のショートカット名と置き換える
tell application "Shortcuts"
tell shortcut id "22590EC1-F6E7-47AD-A040-C29169E9EC63"
run
end tell
end tell
tell application "Shortcuts"
tell shortcut "省エネ"
run
end tell
end tell
| 固定リンク
「AppleScript Shortcuts」カテゴリの記事
- [shortcuts]取得した情報をplistで保存する(位置情報を保存)(2024.12.22)
- PDFからテキスト抽出(AppleScrip・ショートカット(Shortcuts)・Automator 詰め合わせ)(2024.10.25)
- [Shortcuts]macOS14.5 スクリーンキャプチャーが利用できない場合の回避方法(2024.05.17)
- [Shortcuts]URLスキーム(URLからショートカットを実行する)(2024.02.17)
- com.apple.shortcuts.droplet(2023.07.10)