Using the return key in an AppleScript
I'm writing an AppleScript that needs to open files in a legacy program called Intaglio. The issue is that some of my older Intaglio documents are missing some fonts, so when the document is opened, Intaglio throws up a warning dialog before the document window appears. In order to continue, the user needs to hit Return. I have tried to replicate the human behavior of hitting return in the AS, but am having trouble getting it to work. The minimal non-working script is below (assuming "aFile" points to a valid file):
tell application "Intaglio"
open aFile
tell application "System Events"
keystroke return
end tell
end tell
The problem is that when the dialog with the return button appears in Intaglio the script appears to stop, waiting for the return button to be hit. I can only makes it continue by hitting Return manually. Thus the keystroke command is not executed until it's too late.
This seems like a common enough case for using "keystroke." Any suggestions? (Also, I did have it working in an easier version but it stopped after I had made some other changes, but I can't figure out why it is no longer working. I have tried various combinations of "delay" to adjust the timing, to no avail.)