I have recently modified a script I’d written to downsave Quark files from 6 to 5 to 4.
The script has some error handling which generates two logs, one for files completed and the other for files that don’t get completed for some reason. They both work ok.
All seemed fine until the script encountered a file from Quark Passport which had a query regarding French Hyphenation. This only seems to happen when downsaving from 5 to 4 using Quark 5.
The script opens documents ignoring dialogs such as missing fonts, this allows the script to continue running. However when the dialog regarding French Hyphenation pops up the script waits until the user clicks the OK button or presses RETURN.
I’ve had a look through the Quark dictionary to see if I can tell Quark to ignore this, a bit like the missing fonts scenario, however I can’t find anything.
The offending document name gets written to the error log however that’s it, the script then waits.
I have found one solution which involves balancing a stapler on a depressed RETURN key. This works fine however I’d like to avoid the need for the stapler! (or anything else balanced on the RETURN key for that matter!)
Is there a way I can tell applescript to press the RETURN key? Or avoid the dialog?
Further to the above query someone did mention trying the UI Element Inspector to see if System event might be the answer. However due to Quark5 running in OS9 I can’t use the inspector because that only works with Carbon or Cocoa-based applications.
Is there anything else I could use to track down the relevent info in OS9?
I’m not sure if this will help but here’s the completed script. As mentioned above all I need to be able to do is effectively hit the OK button on the warning dialog box that relates to French Hyphenation.
If anyone can help with improving my script that would be appreciated too.
Thanks again.
Nick
on open (someitems)
set doneLogFile to a reference to (path to desktop as string) & "doneList.txt"
set errorLogFile to a reference to (path to desktop as string) & "errorLog.txt"
set savedTextItemDelimiters to AppleScript's text item delimiters
--set AppleScript's text item delimiters to {return}
--set AppleScript's text item delimiters to {":"}
set errorFileList to {}
set doneFileList to {}
set errorFileListLength to 0
set doneFileListLength to 0
display dialog "Which version of Quark?" buttons {"Quark5", "Quark4"}
if button returned of result = "Quark5" then
set qversion to 50
else
set qversion to 40
end if
tell application "QuarkXPress"
activate
repeat with theitem in someitems
try
open theitem remap fonts no use doc prefs yes
if qversion = 50 then
save document 1 in alias theitem version vers 50
else
save document 1 in alias theitem version vers 40
end if
set fileName to (name of (get info for theitem)) as text
set doneFileList to (doneFileList & fileName & return as text)
set doneFileListLength to doneFileListLength + 1
close document 1 saving no
on error
set fileName to (name of (get info for theitem)) as text
set errorFileList to (errorFileList & fileName & return as text)
set errorFileListLength to errorFileListLength + 1
end try
end repeat
end tell
-- write log file containing list of error files
try
open for access file errorLogFile with write permission
set eof of file errorLogFile to 0
write errorFileList to file errorLogFile
close access file errorLogFile
on error errText number errNum
close access file errorLogFile
display dialog errText
end try
-- write log file containing list of files completed
try
open for access file doneLogFile with write permission
set eof of file doneLogFile to 0
write doneFileList to file doneLogFile
close access file doneLogFile
on error errText number errNum
close access file doneLogFile
display dialog errText
end try
display dialog "The number of files processed is:- " & doneFileListLength & return & ¬
"The number of ERROR files is:- " & errorFileListLength
set AppleScript's text item delimiters to savedTextItemDelimiters
end open