I need to try to control a special plug-in pallet in CS2, it is not directly scriptable so I must use UI Scripting to replicate pressing the up arrow, then printing a PS file. Below is the script I am using. It currently prints the first page, then it waits, and then all at once presses the up key all in a row and does not do the other steps in the repeat.
Is there something I am missing? Is there a way to make the app stop and do the other steps before the UI kicks in again?
The script is designed to print the first page that is currently displayed, then repeats pressing the arrow to go to the next record, and then prints that, etc.
global myPath --the path to the location you want to save the PS files to
global aReturn
global aEuro
set aReturn to return --sets a return character to use in text
set aEuro to "€" --sets a character to Euro so we can remove it
set myPath to "Macintosh HD:Users:chrispav:Desktop:test:" --the path to the folder we want to save the files to
tell application "Adobe InDesign CS2"
display dialog "How many records are in this batch to export?" default answer "0"
set myRecordCount to (text returned of result) as number
set myPrintPresetChoice to ("Print PS File PDF7 test") as text
--the printer preset we want to use
tell print preferences of document 1 to set active printer preset to myPrintPresetChoice
--sets the current printer style of the doc to what is here in script
end tell
PrintThePS()
--repeat (myRecordCount - 1) times
repeat 5 times
tell application "System Events"
tell process "Adobe Indesign CS2"
set frontmost to true
keystroke (ASCII character 30) --presses the "up" arrow
end tell
end tell
PrintThePS()
end repeat
on PrintThePS()
tell application "Adobe InDesign CS2"
tell document 1
set myPageSKUCode to (get contents of text frame "SKUcode" of page 1) as text
--gets the text in the box
if myPageSKUCode ends with aReturn then
set myPageSKUCode to characters 1 thru -2 of myPageSKUCode as string
end if
--if there is a return at the end, skip past it
if myPageSKUCode ends with aEuro then
set myPageSKUCode to characters 1 thru -2 of myPageSKUCode as string
end if
--if there is a Euro character, skip that as well
set myOutputPS to (myPath & myPageSKUCode & ".ps")
--set the name of the PS file to print as a string
tell print preferences to set print file to myOutputPS
--tell ID to set the PS file name to output
print without print dialog
--print it
end tell
end tell
end PrintThePS
Model: PM G4 DA + dual 1.8
AppleScript: 10.44
Browser: Safari 416.13
Operating System: Mac OS X (10.4)