applescript for printing
I was told that you could write an applescript that would let you drag and drop a file onto it and it would print it. The person also said that it would bypass the print dialog box, printing the default ONE copy.
Can anyone tell me what that script would be? I don't know how to have the script detect the creator of the file, for one thing.
for creator detection use "standard extra's"
(can't say more about it cause I'm working on pc now)
I guess you want to emulate the way a PostScript desktop-printer normally works (i.e., by directly printing a file without any user intervention), for non-PostScript documents? You could try searching for a suitable script at the various AppleScript websites (e.g., MacScripter.net's ScriptBuilders library), or read on for some possible approaches.
As caifara suggested above, you could readily use the 'info for' command (which was rolled into the 'Standard Additions' scripting addition or OSAX under Mac OS 8.5+) to obtain the creator-code of a drag-&-dropped file or, better yet, directly retrieve the full pathname of the owner application. Alternatively, you could use a couple of commands in the scriptable Finder to accomplish the same thing.
On the other hand, bypassing the Print dialogue to automatically print just "one copy" is a much trickier task. Unfortunately, unlike prompted printing, there is no standard scripting command for automatic one-copy printing. E.g., Tex-Edit Plus uses 'print one copy theseFiles', whereas AppleWorks uses 'print theseFiles with one copy'. To accommodate several applications, you would probably end up to having to write different code for each of them. Moreover, these commands might not always work reliably (e.g., Tex-Edit Plus sometimes ignores the 'print one copy' command if there isn't at least one window already open).
Instead, you could try using one of the freeware OSAXen that can automate typing 'Cmd-P' followed by 'Return', which simulates invoking the Print dialogue via the standard menu-shortcut, and then auto-accepting it via the default button (usually 'Print' or 'OK'). Examples of such OSAXen include Sändi's Additions, Sigma's Additions, etc., which can all be found in the usual Keyboard "folder" of MacScripter.net's Scripting Additions library.
A sample script using the Sändi's Additions OSAX is shown below; you could save it as an applet/droplet from within Script Editor. The script assumes that a printer has already been selected in the Chooser, and it attempts to handle any number of files (possibly having different creator codes).
Regards, and good luck,
[This message has been edited by Paul Crawford (edited 04-19-2001).]
|All times are GMT -4. The time now is 10:17 PM.||
Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2016, vBulletin Solutions, Inc.