Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Delay while printing is being done



Hi people,

I have been working on a script that prints word files as PDF's.  The end result was reasonably effective, however I brought another issue to the fore.  Often when writing scripts I put in a delay of a second or two to ensure that the script does not start a process before another has finished.  The script below is an example.  This script would be much more reliable if it could detect when the printing process finished before attempting to close the file.

try
tell application "Finder" to set thisList to every file in the front window
repeat with i from 1 to the number of items in thisList
set thisItem to item i of thisList
tell application "Finder" to activate
open thisItem
delay 1
tell application "System Events"
keystroke "p" using command down -- print
delay 3
key code 36
delay 15  -->  How do I write a script that detects when it is safe to close the window?
tell application "System Events"
keystroke "w" using command down
end tell
end tell
end repeat
end try


How do I write a script that detects when it is safe to close the window?

Peter Baxter

"Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed."
President Dwight D. Eisenhower, April 16, 1953




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.