Newbies Vartan Posted January 9, 2005 Newbies Posted January 9, 2005 Hello to all those are searching for a solution to the printer bug in FMP7. I dig a few in this and found a solution. Before you go further to find a better solution let me tell you my quest. I have a solution with 2 printers, one for lables one for invoices. As you could imagine, I hope my FM scripts to change printer to LabelWriter for the labels and to HP for the invoices. There's some plug-ins but I was searching for a free solution. I read some thread about scripting the Printer Setup Utility, but this does not work as far as FMP7 doesn't care about the default printer but only about the last used printer. I tried to script the printer change using GUI scripting of Panther (see Apple GUI Scripting) embeded in a DoApplescript step in a FMP Script. But that doesn't work because FMP Scripts are behaving a strange way : - if you put the Do Applescript step after the Print Step. FMP waits for an answer to the print dialog to launch the AppleScript. - if you put it before...The print step is not launch until the AppleScript is finished. - if you wrap the applescript in an "ignoring application responses/end ignoring" the scripts are so melting one with the other that FMP becomes mad - if you forget the Print Step in the FMP script but put it in the AppleScript, it doesn't work because menus are not accessible while a script is running in FMP So what... Here is the only way I found : 1st make an applescript and save it as application 2 nd make your FMP script launch the AppleScript just a step before the Print step here is what my script looks like : the "GotoLabelWriter 320" Applescript tell application "System Events" tell application process "FileMaker" repeat until frontmost --this repeat to be sure FMP is the frontmost app set frontmost to true end repeat repeat until exists window "Imprimer --this one to wait until the printing dialog appears end repeat repeat until value of pop up button 3 of window "Imprimer" is "LabelWriter 320" --and finaly this one to change the printer click pop up button 3 of window "Imprimer" click menu item "LabelWriter 320" of menu "Popup:" of pop up button 3 of window "Imprimer" end repeat end tell end tell here is the FMP Script : Step Do AppleScript = tell application "Finder" ignoring application responses open file "GotoLabelWriter 320" of folder "Documents" of home end ignoring end tell followed by the Print step Hope this helps. Don't forget to Enable access for assistive devices of the Universal Access pane of the System Preferences si that GUI Scripting works in Panther. waiting for comments Regards Vartan
David Melville Posted January 13, 2005 Posted January 13, 2005 What a nightmare! I too have a laser printer that I use to print standard letters, also a Dymo Labelwritter that I use to print labels. (The label is a layout) I have a separate script for each. The Filemaker script is: Go to layout ["Dymo label"] Perform Applescript [forces deafault printer to Dymo] Print [] Go to layout ["original"] The second Filemaker script goes to a different layout and forces default to "Laser Printer" What happens is that it on the second time round it defaults to the previous printer setting ignoring the applescript. I am not able to really understand what you are saying, can you give some more specific and simpler instructions please.
Newbies Vartan Posted January 14, 2005 Author Newbies Posted January 14, 2005 Sorry David, but what you're saying doesn't work, first because FMP doesn't care about the default printer but only about the last used printer, so even if you tell to set the default printer to LabelWriter, if the last used printer is another one it remains selected in the printing dialog. Second you cannot only tell wich is the default printer unless you launch the printer setup utility wich is far more slower than a few lines AppleScript App. Add to this that hanging the layout doesn't change anything to the printer setting else than the printed content. No ? I cannot give simpler explanations, the post is a bit long but most of the story is all the steps I go thru so that nobody else make the same mistakes seeking for a better solution. The way it works is simple : an applescript GUI scripting for each printer, the ASscript is launched by a Perform Applescript [...] Step just before the print step. Using your syntax it would be Perform Applescript [tell application "Finder" ignoring application responses open file "GotoLabelWriter 320" of folder "Documents" of home end ignoring end tell] Print [] The "GotoLabelWriter 320" file is an applescript : tell application "System Events" tell application process "FileMaker" repeat until frontmost --this repeat to be sure FMP is the frontmost app set frontmost to true end repeat repeat until exists window "Imprimer --this one to wait until the printing dialog appears end repeat repeat until value of pop up button 3 of window "Imprimer" is "LabelWriter 320" --and finaly this one to change the printer click pop up button 3 of window "Imprimer" click menu item "LabelWriter 320" of menu "Popup:" of pop up button 3 of window "Imprimer" end repeat end tell end tell that's all and that's the only way i found to switch printers. If you have a better solution tell me I would be very glad to use it. Vartan
Newbies Dan Burgess Posted January 20, 2005 Newbies Posted January 20, 2005 Thanks Vartan for the great work. One little note, to make this work on an English Mac OS X, you have to change the window name to "Print" from "Imprimer". I prefer to use an AppleScript within FileMaker to script Printer Setup Utility to set the default printer, then one compliled AppleScript application that changes the Print window's printer menu to the default printer. 1st script (in FileMaker - calculated AppleScript - printer name is script parameter): // Set default printer to script parameter "tell application "Printer Setup Utility"
dkemme Posted January 25, 2005 Posted January 25, 2005 Ohh, I'm so close... Everything works great with the first switch, but with the next switch, the printer does not change in the print dialog. I've noticed that the AppleScript Application I created using Dan Burgess' method is still running, preventing it from running the second time completing the change. This happens whether I am running the script in Script Editor or if I save as an app with the options 'Application' and choosing only 'Run Only' and not choosing 'Stay Open' or 'Start Up Screen'. It just won't quit at the end, keeps on running. I have enabled assisted devices in the universal access system panel. Below is my script. Any suggestions? tell application "Printer Setup Utility" activate set the PrinterName to the name of the current printer end tell tell application "System Events" tell application process "FileMaker" repeat until frontmost set frontmost to true end repeat repeat until exists window "Print" end repeat repeat until value of pop up button 3 of window "Print" is PrinterName click pop up button 3 of window "Print" click menu item PrinterName of menu "Popup:" of pop up button 3 of window "Print" end repeat end tell end tell
D-fendr Posted March 29, 2005 Posted March 29, 2005 I have the same problem when trying either method. Script(s) works first time, keeps running, doesn't work second time - to switch to another printer. If I force quit the script and reselect printer in restore, print step, it works for that printer, til I try to switch again. All of which defeats the purpose of the script. Whoever comes up with a bulletproof method to switch printers back and forth and posts the file here should have mega-kudos heaped upon them. (Of course if FileMaker would just post a fix, then...)
D-fendr Posted March 29, 2005 Posted March 29, 2005 Thank you very much for your reply. I'm not competent at applescript. However... I downloaded the file. It calls an app: CancelPrinting, which I got from your post on another thread, saved and selected it in the CancelPrint script step. This worked the first time, and the approach seems to work every time. However, after the first run I keep getting an error from System Events: NSReceiverEvaluationScriptError: 4 and I'm left with the print window open in the Cancel step. I've tried increasing the delay, but it still seems to hang before executing the "Cancel" step. The script I'm using for the app is below. Thanks again.. tell application "System Events" tell application process "FileMaker" repeat until frontmost --this repeat to be sure FMP is the frontmost app set frontmost to true end repeat click menu item "Print
dkemme Posted March 29, 2005 Posted March 29, 2005 Take a look on your dock, I wonder if CancelPrint is still running. Make sure you saved the CancelPrint as an application without any check boxes selected. This will make the app you created in AS stop after you call it. Also make sure you have enabled access for assitive devices. If still no luck try a delay of 2-4 after ...menu bar 1, maybe your machine is a little slower.
D-fendr Posted March 29, 2005 Posted March 29, 2005 Check on all the above. I've tried delays up to 15. I don't think CancelPrint still running is an issue, it's definitely not running when I try the script after restarting. I get an error, it bounces in the dock and clicking OK quits the app. So I think it would quit ok if it didn't error. With long delay, takes longer for the error to occur, the dialog box is up, front, and ready. It just errors when it gets to: click button "Cancel" of UI element 4 of window "Print" I don't know why it worked once and then not since; I'll keep fiddling somehow. Sorry for the hassle, greatly appreciate your time and effort.
D-fendr Posted March 29, 2005 Posted March 29, 2005 Hold the presses, I think I found it!!! When I changed the 4 to 5 in the cancel step, thus: click button "Cancel" of UI element 5 of window "Print" it works! If it's counting the "?" (Help) button on the far left, that makes "Cancel" number 5 maybe? Again, I'm an applescript dummy, but it's working every time now. Thanks very much...
dkemme Posted March 30, 2005 Posted March 30, 2005 Good job, it was to be my next suggestion. The problem here is that different printers have different elements! This makes your solution good for your printer, mine for mine, but no global solution. I sure hope Filemaker solves this with v>3! PS You are now an Applescript GUI scripting pro. DJK PPS The UI Elements program or PreFab UI programming aids can help others solve similar probs with other printers.
D-fendr Posted March 30, 2005 Posted March 30, 2005 I'm checkin' 'em out: http://www.apple.com/applescript/uiscripting/ http://www.prefab.com/uibrowser/ Looks very helpful. Hoping the widgets/gadgets/whatever promised in the new OS will maybe make it easier on us script-impaired folks. Really appreciate all your work... thanks.
D-fendr Posted March 30, 2005 Posted March 30, 2005 Installed the scripts at a client (had to change the 5 back to 4) and found one gotcha that you likely realize, but others reading this thread should know... If you have a user whose privledge set: Available Menu Commands = Edit Only, the menu command File/Print will not be available to them, so the script can't execute as written. D-
Newbies Vartan Posted May 24, 2005 Author Newbies Posted May 24, 2005 Hey guys here is a wonderfull solution from rlaan on MacOSXHints. See http://www.macosxhints.com/article.php?story=20050513090541900#comments I didn't find better way to change default printer Vartan
dkemme Posted May 25, 2005 Posted May 25, 2005 FMP7 still prints to the printer last utilized when printing without dialog, even though above steps do select a new default printer. I am going to try and print to a PDF file, then use applescript to print the PDF, either through Preview or some other program. Hopefully Preview or the other program will not have the problems FMP does in recoginzing a changed printer.
dkemme Posted June 4, 2005 Posted June 4, 2005 Here is what I am trying for faxing and ought to work for printing. Check out this hint first: http://www.macosxhints.com/article.php?story=20031128150928128 Print without dialog to postscript file, 10.3 it is the output option, 10.4 it is in the PDF selection, save to post script file. Perform Applescript 'Do Shell Script "lp -d Printer_Name ~/Desktop/filename.ps" I imagine that FM will be stuck printing all to the postscript file, but then you will have the ability to send to any printer/Fax you want. lp does have the ability to change options in the printer with the -o command, as you can see in the OSXHints on faxing, and I imagine these options could control paper selection, but I have been unable to test or find documentation but I bet it is somewhere here, just without the interest in learning at the moment: http://www.linuxprinting.org HTH.
Newbies lizard294 Posted August 3, 2005 Newbies Posted August 3, 2005 I have run into this exact bug and am stuck. I am trying to print forms to seperate printers, and of course filemaker only honors the most recently selected printer in both scripts. I am attempting the postscript -> lp -d workaround, but I am having trouble setting the paper tray from the command line. Using 'lp -d PrinterName -o media=Tray1' (or upper) doesn't work, and the printer still automatically uses the default feed. Any suggestions? Has anyone come any closer to solving this filemaker problem, or at least gotten filemaker to honor the default system printer choice? Thanks!
dkemme Posted August 14, 2005 Posted August 14, 2005 I do not know how to get the lp to choose paper trays but I bet searching the net for unix printer will lead you to a site I found just for Unix printing questions. Filemaker is working on this problem and help is on the way, no idea how soon though.
dkemme Posted August 29, 2005 Posted August 29, 2005 Initial testing of FM 8 reveals that this "bug" has been solved. Printing without dialog no longer goes to the last printer used by FM but will change when changed in Printer setup. I imagine this means that the changing of printers can be easily scripted, I will let you know after I have had a bit more time testing.
Newbies tallaghtGuy Posted August 30, 2005 Newbies Posted August 30, 2005 I just downloaded the trial version for FMP8, and this BUG is still there.
Lee Smith Posted August 30, 2005 Posted August 30, 2005 Well, there seems to be a difference of opinion on whether this was changed or not? :rofl:
Newbies tallaghtGuy Posted September 10, 2005 Newbies Posted September 10, 2005 Nope, that doesn't work... and even if it did, the fact that you need to call an Applescript to change the printer is not a FIX for a very very annoying BUG. Perhaps it is something to do with the speed of the printer I am using, my client needs to print certain documents to a DMP so that his customers can sign for delivery (and the driver doesn't end up having to bring 2 separate documents with him). It would appear that all of the work arounds are beaten by the fact that the dot matrix is still printing when I attempt to print to another printer (a situation that I only found out about after I had deployed the lpr solution, it arose in the production environment, and I have to say the client was not in the least bit impressed.) At this stage, I have lost a client (and quite a bit of money) as a result of this bug, and I know for a fact that it will be a cold day in hell before I do another FMP installation. This bug has been around for ever, and FileMaker have done nothing to fix it. Sorry for the rant, but it helps to vent now and again.
Newbies Matts Agelii Posted September 29, 2005 Newbies Posted September 29, 2005 Hi guys! Frustration also for me, is it so hard to get this thing right? With FM8 it's just a little bit better than in FM7. The FileMaker Application no longer ignores the OS level default printer. Thus the ugly workaround with CancelPrint in FM7 is no longer needed. The simple AppleScript approach suggested here works fine to change the default printer at the OS level. I'm trying this simple AppleScript approach for my multi-site POS solution. It means hard coding printer names into ScriptMaker. I could of course do more of AppleScripting to aquire a list of available printers, but I'm not very comfortable with too much AS... A tempting alternative would be using Productive Computing´s Change Printer Plug-in here. I´ve tried it with FM8 and it seems to work well. Anyone with a smarter approach to FM8 MacOS X printer automation? / Matts
Bailey Kessing Posted December 30, 2005 Posted December 30, 2005 Chalk one more hack needed to deal with FM and it's ability to do what it should.
Recommended Posts
This topic is 7250 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now