« CODA (Child of Deaf Adults) | トップページ | Shodo - 日本語校正クラウド »

[AppleScript]キーノートの書類サイズを指定して作成

自分でも『どうかしてるんじゃ?』と思うけどね…笑

選んだサイズで
Screencapture_666x498_20220109172241

書類作るだけ…
(その都度計算すれば良いじゃん…てのは無しで…苦笑)

Screencapture_536x560_20220109172241


ダウンロード - 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

|

« CODA (Child of Deaf Adults) | トップページ | Shodo - 日本語校正クラウド »

AppleScript」カテゴリの記事