Change/switch priinters

I am trying to create a script to run on Tiger which will allow me to switch printers whilst a print labels and then switch back. I have created a simple script which is as follows

tell application “Printer Setup Utility”
activate
set myprinter to “Lexmark”
set target_printer to myprinter

end tell

I have tried various combinations of target printer or target_printer, I tried set default_printer to “printer name”

Any help would be much appreciated.

Any suggestions as to where i can find good tutorials would be good

Many thanks in advance

Model: Minimac
AppleScript: 1.10.3
Browser: Internet Explorer 6.0
Operating System: Mac OS X (10.4)

This little script will toggle between two Printers. With a little more tweaking of the “if” statement you can extend that to more than two and just cycle through them. Tested in Tiger - don’t know about Panther or Jaguar. Doing it this way has the advantage that you don’t have to know the name of the printers at all. The dialog announces which is selected and goes away in 3 seconds.

tell application "Printer Setup Utility"
	set myPrinters to every printer
	set DefaultPrinter to current printer
	if item 1 of myPrinters is DefaultPrinter then
		set current printer to item 2 of myPrinters
	else
		set current printer to item 1 of myPrinters
	end if
	display dialog (name of current printer) as text default button 1 buttons {"OK"} giving up after 3
	quit
end tell

There is no way that I’ve ever found of telling whether the printer is actually powered up because all this works just as well if the printer in question is off.

Your script works fine in Script editor but i get inconsistant results when using it in Filemaker. Sometimes the printer changes and sometimes it doesnt. I have hacked the script back to a minimum and added a delay into the FM Pro scipt to give it a bit of time. Any ideas?

There are 2 scipts to set up the printers

tell application “Printer Setup Utility”
set myPrinters to every printer
set the current printer to printer “Lexmark”
end tell

tell application “Printer Setup Utility”
set myPrinters to every printer
set the current printer to printer “LabelWriter 330 Turbo”
end tell

Any help would be gratefully received

Regards

Not sure what you mean by “when using it in Filemaker”, and don’t use Fm, so not likely to be of much help. Given that your scripts work standalone and mine works stand alone (mine with a Fastscripts key combination to switch from a Laser Printer to an Ink Jet), then it seems likely that the problem arises with Filemaker. Sorry.

Adam

On second thought, perhaps if you put the script in your ~/Library/Scripts folder and in the Fm scripts folder just put the line: run script alias (path to scripts folder as text) & “yourScriptName.scpt”, that might work.