Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Switch printers using Terminal in FileMaker Pro' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Switch printers using Terminal in FileMaker Pro
Authored by: Krioni on May 23, '05 05:39:40PM
Um, actually, you CAN change the default printer without using UI Scripting. The Printer Setup Utility is scriptable. Here's code that let's you change the default printer:


set pickPrinterName to "HP LaserJet 4050 MCP" -- or whatever name you want

tell application "Printer Setup Utility"
	set matchingPrinters to every printer whose name is pickPrinterName	set current printer to (item 1 of matchingPrinters)
end tell

Now for the bad news: FileMaker Pro 7 (FM Pro 6 is OK) really does not honor your change of the default printer. If you have not yet printed anything in FileMaker 7, it will use the default printer. If, however, you HAVE printed already, it ignores the fact that you changed the default printer and sticks with whatever printer FileMaker 7 last used. If you change the default printer BEFORE you have printed in FileMaker 7 (since it was launched), it will use the new default printer. The bad news there is that if you then try to switch the default printer BACK, FileMaker doesn't notice, and keeps using the last printer it printed with, at least until you quit and re-launch FileMaker.

So, there is no way to get FileMaker 7 to notice that you have switched printers. It stubbornly continues to use the last printer it used, no matter what you do, unless you actually PICK a different printer from the print dialog WITHIN FileMaker 7. Infuriating. FileMaker 6 DOES honor the default printer. Imagine that.

[ Reply to This | # ]

Switch printers using Terminal in FileMaker Pro
Authored by: Vartan on May 24, '05 06:58:47AM
OK Krioni,

you're right the printer setup utility is scriptable, but this suppose to launch this app wich is time consuming.

I had build a solution using GUI Scripting, wich you can read on FMForums
It was really difficult to make this work because of timing problems between FMP Scripts and AppleScripts. This Cups solution is far more better, no other app to launch, no special external scripts to call, no need to activate GUI scripting, and last no delay.

Congratulations, I'm sure your solution will be appreciated by the FMP community.

Regards

Vartan

[ Reply to This | # ]

Switch printers using Terminal in FileMaker Pro
Authored by: Krioni on May 24, '05 06:32:48PM

Vartan,

But does it _work_? Did you read my description of how FileMaker 7 ignores the default printer once you have printed? Does your solution get around this annoying (and wrong) behavior of FileMaker 7, or does yours also only work on FileMaker 6?



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: Vartan on May 25, '05 03:42:21AM

It works but it's far more compllicated than switching the default printer from shell script. My solution uses GUI Scripting and makes what you would have done : switch the printer from the printer local menu in the printer dialog.
To avoid timing problem between FMScripts and AppleScripts I have been obliged to build external AppleScripts, called from FMScripts.

Vartan



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: Vartan on May 25, '05 04:01:40AM
Ok Krioni, You're right (again :-) and pardon me. FMP remains stuck with last used printer whatever is the way you change the default printer (Printer Setup Utility or Shell script). So the only solution, wich is not so smart, is to use GUI Scripting as I describe in FMForums .

Excuse me, I was so happy finding a new way to deal with this bug that I made congratulations before trying to make it work.

Regards

Vartan

[ Reply to This | # ]

Switch printers using Terminal in FileMaker Pro
Authored by: Krioni on May 25, '05 01:08:20PM

No problem - I work extensively with FileMaker and find it infuriates more often than it impresses. :-( Amazingly enough, it's probably still better than anything else out there (at least for rapid development).

Side note: the FM Forums are very irritating. It seems you have to pay to access anything there, although it seems to indicate you can get in without paying after you register. I went through the whole process of registering, but then was stymied trying to view an old post. I felt like I had been "led on" by the whole thing.



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: rlaan on May 26, '05 03:38:00AM

Hi, just to let you know, my Filemaker 7 DOES listen to my default printer using this script. So why is that? Else I wouldn't have posted all this ;-)

What I do is an extensive script that askes the user for a number of fields to fill and the first line of the script is the switching of the printer. Maybe Filemaker needs a second to re-load the printer setting?

Ruben (rlaan)

---
The box said, Windows 95 or better, so I bought OS X.



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: rlaan on May 26, '05 03:54:51AM

Just to make things certain, after using this scriptcode I turned ALL filemaker printersettings off in the script, so basically I print without page and printer setup and I just show the print dialog to check that the right printer is indeed selected... And it has been for the last week.

Funny thing, using other printers in a diffrent filemaker app seems to work fine using the official Filemaker method... The behaving is eratically...

Ruben

---
The box said, Windows 95 or better, so I bought OS X.



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: Greg Torok on May 27, '05 11:25:21AM

I really, really, really wished this worked for me, but setting this up to switch and print multiple jobs to multiple printers within a single FileMaker script is still not working. I removed all Page Setups and Print settings and still no joy.

I'm trying to use this to change to multiple printers and print within a single script. Basically I need, in one script, to change to a small label printer, print a label, change to a large label printer, print a different label, change to a laser printer and print a document.

Has anyone been able to get this to work to print a document to printer A, switch to printer B and print it there too, then switch back to printer A all within one script or series of scripts, without hitting Cancel at the print dialog (because that seems to clear FileMaker's preference for the last used printer, then the next dialog shows the correct printer)?

Even when I use the Shell method, unless I Cancel a print request between each printer change, Filemaker retains the last used printer regardless of the current default. I'm using GUI scripting to cancel a print job between each new printer selection, which I'd like to get away from as it slows things down.



[ Reply to This | # ]
Switch printers using Terminal in FileMaker Pro
Authored by: EricW on May 26, '05 06:45:17PM

Haven't fully tested this but as others have said for FM developers it's priceless. One question I have. (Good grief sounds like Yoda !)
OS X native pdf printing isn't within the lp framework. Has anyone explored the same appproach to hook pdf printing. Adobe pdf is there but not everyone shells out for that. Pdfwriter is an option but it wouold be nice to access the native.



[ Reply to This | # ]