I’ve just posted a solution to circumvent a bug of FileMaker Pro 7 at fmforums and I’m sure this could help other people wanting to change the printer by scripts even if they don’t use FMP7.
The bug is that in previous versions, FMP was recording the printer name within its Printer Setup step of his scripts. Since version 7 FMP prints to the last used printer whatever you do in your script.
I have found so many help reading this forum that I thought it was my turn to give something.So …
I dig a few in this problem 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
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 http://www.apple.com/applescript/uiscripting/)
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
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