Hi,
I am attempting to automatically print two copies of a text file as soon as the file is saved in a specific folder. Text Edit automatically launches, removes the first 90 characters, then brings up the print dialog. I have attempted to have the script to type the number 2 where the number of copies shows up in the print dialog box, but it just seems to skip that and print one copy instead. All of this is being run on Mac OS X Server 10.4.5.
Ultimately, I would like to have any text file named 1.txt to print 1 copy and 2.txt to print 2 copies, but I cannot even get the 2 copies to work so I’ll deal with the next part after I get this figured out.
Here is what I have so far. I am a novice, so please excuse any odd formatting.
on adding folder items to this_folder after receiving added_items
repeat with each_item in added_items
tell application “TextEdit” to open each_item
tell application “TextEdit”
activate
end tell
tell application “System Events”
key code {125}
repeat with i from 1 to 90
key code {51}
end repeat
key down command
keystroke “p”
key up command
tell sheet 1 of window 1
repeat until exists
delay 0.1
end repeat
key code {84}
key code {36}
end tell
end tell
delay 20
tell application “Finder” to delete each_item
tell application “System Events” to do shell script "kill " & (unix id of first process whose name is “TextEdit”)
end repeat
end adding folder items to
Thanks,
Fletch