Repeat the same tasks for many files
The following script opens Acrobat and prints all the .PDF files present in a directory.
You can find the corresponding script file under Script_Examples, sub-directory of scripts.
' Script printing all the pdf files present in a subdirectory.
' Acrobat reader must be installed and the name of acrobat application
' is acrord32. Set DIREC$ to the name of the subdirectory where the pdf files are.
dim longname$(500)
dim shortname$(500)
dim att$(500)
'If Acrobat Reader is not yet launched, the script launched it.
if isrunning("ACRORD32.EXE")=0 thenshell("acrord32")
pause 8
endif
DIREC$="c:\wintask\pdf\" ' will not recurse subdirectories
nb=dir(direc$+"*.pdf",longname$(), shortname$(), att$(), "")
if nb=0 then msgbox("no file to process !") end endif
i=0
repeat
UseWindow("ACRORD32.EXE|Afx:400000:|Acrobat Reader",1)
'We use the keyboard shortcut for File/open menu
sendkeys("<alt f>o") 'file open
UseWindow("ACRORD32.EXE|#32770|O",1)
WriteEdit("1",direc$+longname$(i))
sendkeys("<alt o>") 'open keyboard shortcut
pause 2
UseWindow("ACRORD32.EXE|Afx:400000:|Acrobat Reader",1)
sendkeys("<ctrl p>") ' print
pause 1
usewindow(top$())
sendkeys("<enter>")
pause 3
'The printing can take a while, and the must not open a new PDF file before it has finished printing.
'With this loop, we wait until the window on top (the one telling that it prints) is not there anymore.
repeatpause 200 ticks
EndPause
until top$()<>"ACRORD32.EXE|#32770|Acrobat Reader"
PAUSE 1
i=i+1
until i=nb