Keynote/Pagesの書類上の「表」のうち、選択中のカラムについて「幅」を均等割する(等しい幅に設定する)AppleScriptです。Keynote/Pages v14.0で動作確認していますが、とくにバージョン固有の機能などに依存する部分はありません。
▲Keynote書類上の表のカラムを選択しておいてAppleScript実行
▲Keynote書類上で選択しておいた表カラムが均等幅に設定される
▲Pages書類上の表のカラムを選択しておいてAppleScript実行
▲Pages書類上で選択しておいた表カラムが均等幅に設定される
AppleScript名:選択中の表カラムの幅を均等割.scpt |
— – Created by: Takaaki Naganoya – Created on: 2024/05/05 — – Copyright © 2024 Piyomaru Software, All Rights Reserved — tell application "Keynote" tell front document set aSel to selection set fObj to class of first item of aSel if fObj is not equal to table then display notification "tableが選択されていません" return end if tell current slide try set theTable to first table whose class of selection range is range on error display notification "table中のセル(カラム)が選択されていません" return –何も選択されてなかった場合 end try tell theTable set vList to address of column of every cell of selection range set vUList to uniquify1DList(vList) of uniquifyKit of me –均等割したカラム幅を計算 set totalW to 0 repeat with i in vUList tell column i set tmpW to width set totalW to totalW + tmpW end tell end repeat –選択カラム幅に均等割した幅を設定 set aColW to totalW / (length of vUList) repeat with i in vUList tell column i set width to aColW end tell end repeat end tell end tell end tell end tell script uniquifyKit use scripting additions use framework "Foundation" property parent : AppleScript on uniquify1DList(theList as list) set theSet to current application’s NSOrderedSet’s orderedSetWithArray:theList return (theSet’s array()) as list end uniquify1DList end script |
AppleScript名:選択中のカラムの幅を均等割.scpt |
— – Created by: Takaaki Naganoya – Created on: 2024/05/05 — – Copyright © 2024 Piyomaru Software, All Rights Reserved — tell application "Pages" tell front document set aSel to selection set fObj to class of first item of aSel if fObj is not equal to table then display notification "tableが選択されていません" return end if try set theTable to first table whose class of selection range is range on error display notification "table中のセル(カラム)が選択されていません" return –何も選択されてなかった場合 end try tell theTable set vList to address of column of every cell of selection range set vUList to uniquify1DList(vList) of uniquifyKit of me –均等割したカラム幅を計算 set totalW to 0 repeat with i in vUList tell column i set tmpW to width set totalW to totalW + tmpW end tell end repeat –選択カラム幅に均等割した幅を設定 set aColW to totalW / (length of vUList) repeat with i in vUList tell column i set width to aColW end tell end repeat end tell end tell end tell script uniquifyKit use scripting additions use framework "Foundation" property parent : AppleScript on uniquify1DList(theList as list) set theSet to current application’s NSOrderedSet’s orderedSetWithArray:theList return (theSet’s array()) as list end uniquify1DList end script |
More from my site
(Visited 3 times, 3 visits today)