[AppleScript]キーノートの書類サイズを指定して作成
自分でも『どうかしてるんじゃ?』と思うけどね…笑
書類作るだけ…
(その都度計算すれば良いじゃん…てのは無しで…苦笑)
ダウンロード - keynotoe381aee69bb8e9a19ee382b5e382a4e382b9e38299.zip
(************************************************************************
PPDファイルを利用して
キーノートの新規書類を作成します
→ポイント指定なので計算面倒だからね
20220109 初回作成
************************************************************************)
on run
set aliasPathToMe to path to me as alias
tell application "Finder"
set theMeFileName to name of aliasPathToMe as text
end tell
set thePathToMe to (POSIX path of aliasPathToMe) as text
set thePathToMe to doReplace(thePathToMe, theMeFileName, "")
set thePathToMe to ("" & thePathToMe & "/ppds/") as text
set aliasDefLoc to (POSIX file thePathToMe)
set theWithPrompt to "PPDファイルを選択してください(gz圧縮ファイルは解凍してから)"
--set theDefLoc to path to printer descriptions folder from local domain
set theDefLoc to aliasDefLoc
set theFileType to "com.adobe.postscript,com.adobe.ppd,public.ppd,public.data" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
open (choose file default location theDefLoc ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
without invisibles)
end run
on open DropObj
set thePaperListAll to "" as text
set theFilePath to POSIX path of DropObj
set theReadData to (do shell script "cat '" & theFilePath & "'") as text
set AppleScript's text item delimiters to "\r"
set listData to (every text item of theReadData) as list
set AppleScript's text item delimiters to ""
set numCntList to (count of listData) as number
set numReadList to 1 as number
repeat numCntList times
set theLineData to (item numReadList of listData) as text
if theLineData contains "*?PageSize:" then
set numInList to 1 as number
set numInStartList to numReadList as number
repeat
set numInStartList to numInStartList + 1 as number
set theInData to (item numInStartList of listData) as text
if theInData contains "] (" then
set theInData to doReplace(theInData, "dup ", "") as text
set theInData to doReplace(theInData, " put", "") as text
set theWpt to word 1 of theInData as text
set theHpt to word 2 of theInData as text
set AppleScript's text item delimiters to "("
set listInData to (every text item of theInData) as list
set AppleScript's text item delimiters to ""
set thePaperName to (item 2 of listInData) as text
set thePaperName to doReplace(thePaperName, ")", "") as text
set thePaperList to ("" & thePaperName & "\t" & theWpt & "\t" & theHpt & "") as text
log theInData
log thePaperName
log theWpt
log theHpt
log thePaperList
set thePaperListAll to (thePaperListAll & "\r" & thePaperList) as text
end if
if theInData contains "*End" then
exit repeat
end if
end repeat
log thePaperListAll
end if
set numReadList to numReadList + 1 as number
end repeat
set thePaperListAll to thePaperListAll as text
set AppleScript's text item delimiters to {(ASCII character 13)}
set listPaperListAll to (every text item of thePaperListAll) as list
set numChkDelimiters to (count of listPaperListAll) as number
set AppleScript's text item delimiters to {""}
set theResponce to choose from list listPaperListAll with title "作成する用紙を選んでください" with prompt "作成する作成する用紙を選んでください" without multiple selections allowed and empty selection allowed
if theResponce is false then
error number -128
end if
set theResponce to theResponce as text
set AppleScript's text item delimiters to {(ASCII character 9)}
set theDataListLineData to every text item of theResponce as list
set AppleScript's text item delimiters to {""}
set theLineDate1 to (item 1 of theDataListLineData) as text
set theLineDate2 to (item 2 of theDataListLineData) as text
set theLineDate3 to (item 3 of theDataListLineData) as text
tell application "Keynote"
launch
activate
make new document with properties {name:"" & theLineDate1 & "", width:"" & theLineDate2 & "", height:"" & theLineDate3 & "", slide numbers showing:true}
end tell
end open
--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace
| 固定リンク
「AppleScript」カテゴリの記事
- 濁音 半濁音 置換用レコード(2023.08.21)
- [AppleScript]キーノートの書類サイズを指定して作成(2022.01.09)
- [awk]行頭のスペースを削除する(subで置き換え)(2021.11.16)
- [SpotLight]選択範囲でSpotLight検索(2021.11.03)
- [AppleScript]リソースフォーク(カスタムアイコン)削除(2021.10.12)