メニュー項目から「透かしのを追加…」がなくなってしまいました。。
プリントダイアログも大幅に変わり、ほぼUIelementでしか操作できないAcrobatでこの変更は痛い。。
なので、スクリプトを組む前に下準備。
「表示」→「ツールセット」→「新規ツールセットを作成…」
ツールセットに「透かし」を追加。保存。
名称はとりあえずそのまま「名称未設定」。
透かしのプリセットを適当に作成。
名称はとりあえず「透かし」。
「テキスト」部分にとりあえず「uni-factory」と入れておく。
マウスクリックは下記を参考にというかそのまま使っています。ありがとうございます。
http://memogakisouko.appspot.com/index.html
以下スクリプト。プリセットを基準に「テキスト」部分を変更します。
スクリプトエディタで開く
tellapplication“System Events”
tellapplication process“AdobeAcrobat”
seta1tonameofwindow 1 —ドキュメント名を取得
clickmenu item“名称未設定“ofmenu“名称未設定“ofmenu item“名称未設定“ofmenu“表示“ofmenu bar item“表示“ofmenu bar 1 –ツールセットにつくった「名称未設定」を呼び出す。
delay 0.1
copypropertiesofwindow 1 to {position:{mp1, mp2}, size:{mp3, mp4}} –名称未設定→「透かし」の位置をウインドウの位置から取得。
mc({mp1 + mp3– 150, mp2 + 160}, “left”, 1, “”, 0.1) ofme–「透かし」をクリック。参考URL:http://memogakisouko.appspot.com/index.html
mc({mp1 + mp3– 150, mp2 + 200}, “left”, 1, “”, 0.1) ofme–「透かしを追加…」をクリック。
tellcurrent applicationtosets1todo shell script“date +%Y年%m月%d日%H時%M分“–時間取得
delay 0.1
repeatuntil (nameofwindow 1 = “透かしを追加“) –「透かしを追加」ウインドウが出てくるのを待つ。
delay 0.2
endrepeat
tellwindow“透かしを追加“
clickmenu item“透かし“ofmenu 1 of (clickpop up button 1) –プリセット「透かし」を開く。
repeat
try
ifvalueoftext area 1 ofscroll area 1 ofgroup“ソース“ = “uni-factory”thenexitrepeat–プリセットの読み込み終了を待つ。
endtry
delay 0.2
endrepeat
setvalueoftext area 1 ofscroll area 1 ofgroup“ソース“toa1& “初校“& s1–ドキュメント名&初校&時間を入力。
delay 0.1
clickbutton“OK”
endtell
endtell
endtell
onmc(thePosition, theButton, theClickCount, theModifierKeys, thePressSec)
settheModifierKeystotheModifierKeys& ” – “
setthePressSecTexttothePressSecastext
settheRubyScriptto“require ‘osx/cocoa’;\nif ARGV[0] == ‘mouse’ then\nevent=OSX::CGEventCreate(nil);\npos = OSX::CGEventGetLocation(event);\nprint pos.x , ‘,’, pos.y;\nelse\npos = [ARGV[0], ARGV[1]];\n\nend\n\nbuttonInput = ARGV[2];\nclickCount = ARGV[3].to_i;\nmodifierKeys = ARGV[4];\nthePressSec = ARGV[5].to_f;\n\nif buttonInput == ‘left’ then\nbutton=0;\neventTypeDown=1;\neventTypeUp=2;\nend\n\nif buttonInput == ‘right’ then\nbutton=1;\neventTypeDown=3;\neventTypeUp=4;\nend\n\nif buttonInput == ‘middle’ then\nbutton=2;\neventTypeDown=25;\neventTypeUp=26;\nend\n\neventFlag = 0;\n\nif modifierKeys.index(‘command’ ) != nil then\neventFlag |= 0×00100000;\nend\n\nif modifierKeys.index(‘shift’ ) != nil then\neventFlag |= 0×00020000;\nend\n\nif modifierKeys.index(‘option’ ) != nil then\neventFlag |= 0×00080000;\nend\n\nif modifierKeys.index(‘control’ ) != nil then\neventFlag |= 0×00040000;\nend\n\nif modifierKeys.index(‘fn’ ) != nil then\neventFlag |= 0×00800000;\nend\n\nif modifierKeys.index(‘caps’ ) != nil then\neventFlag |= 0×00010000;\nend\n\n\n\nev=OSX::CGEventCreateMouseEvent(nil, eventTypeDown, pos, button);\nOSX::CGEventSetIntegerValueField(ev, 1, clickCount);\nOSX::CGEventSetFlags(ev, eventFlag);\nOSX::CGEventPost(0,ev);\n\nsleep thePressSec;\n\nev2=OSX::CGEventCreateMouseEvent(nil, eventTypeUp, pos, button);\nOSX::CGEventSetIntegerValueField(ev2, 1, clickCount);\nOSX::CGEventSetFlags(ev2, eventFlag);\nOSX::CGEventPost(0,ev2);\n”
tellcurrent applicationtodo shell script“/usr/bin/ruby -e “& quoted formoftheRubyScript& ” “& item 1 ofthePosition& ” “& item 2 ofthePosition& ” “& theButton& ” “& theClickCount& ” “& quoted formoftheModifierKeys& ” “& quoted formofthePressSecText
endmc