How can I trigger an AppleScript to play a sound when a job is printed

How can I trigger an AppleScript to play a sound when a job is printed to a specific printer?

I have a PrintServer that FileMaker prints files to as a remote USB printer. I need to trigger a sound on the PrintServer whenever FileMaker sends a job to one specific printer (we have three printers on the PrintServer). I assume that I will need an AppleScript that is triggered on the PrintServer whenever it prints to the target printer.

Is it possible to do this?

Hi Pchater

i’m sure this is possible there’s a lot of talented scriptors on this forum who are very willing to help.
you might need to supply abit more info, and one hard thing is to reproduce somebody else’s set-up.
all these things could point to why nobody has answered your post…

The Printer Setup Utility is scriptable. Can you see this USB printer there?

Where is the queue for that printer - on your machine or on the “parent” machine?

We need more info as Pidge1 has pointed out.

There are three computers.

1.) POS WaitStaff
2.) POS Bar
3.) Printserver

There are three printers connected to the print server via USB.

1.) Kitchen
2.) Bar
3.) Coldside Back

When a person places an order at the POS computer a ticket is printed to each zone of the restaurant via the print server which hosts all of the printers. We have created a shared printer queue on each POS station but I am not familiar enough with how it passes the job to the print server. I assume that everything passes through the print queues on the print server. It seems like the printers all work even when there are no users logged in on the print server.

The kitchen is loud and they can not hear the printer. We have connected a speaker to the print server and we are trying to figure out how to trigger a specific sound file that alerts the cooks that an order has come in.

If we just had one POS it would be easy, I could simply tell the FileMaker’s print script to play the sound. Where I am stumped is trying to figure out how to trigger the sound from the print server.

I guess I don’t understand - If there’s only a printer in the kitchen, what’s going to make the sound for them to hear? Is the print server a Mac that’s in the Kitchen?

The speaker that is connected to the print server.

Is there a print queue folder that I can monitor for activity and the use it to trigger a script?

Helping you is like pulling teeth: If the print server is a Mac, running this will tell you whether it’s busy:

tell application "Printer Setup Utility"
	set P to current printer
	set j to name of jobs of P
end tell

Okay, sorry Adam…let me clarify.

All of the computers that we are using are Macs.

The print server is located in a back office that is approximately 40 feet from the kitchen.

There is a 50 foot audio cable connected to the speaker output on the print server.

There is a 50 foot CAT5 USB extender connected to the Print Server with a StarMicronics receipt printer connected to it.

Thanks for the Scriplet, I am not quite sure how to use it to trigger a sound but I will forward it to someone else in our office that has a better understanding of AppleScript.

After playing with my own setup here, I’m not convinced that the scriptlet is useful to you. While I was printing a large job it didn’t show anything. There has to be a way, but I haven’t found it. What is really wanted is a script to detect that a print job has come in and been sent to the printer because printing it will be fast anyway for the sort of thing you’re printing.

Turns out this idle handler (saved as a stay-open application) works:

on idle
tell application “Printer Setup Utility”
if status of current printer is printing then beep 2
return 2
end tell
end idle

During a print download to the printer it beeps twice, waits 2 seconds, and beeps again.

Thanks very much Adam, I will give it a try and let you know if it works. My concern is that I do not see any activity on the print server when a receipt prints from either POS terminal. I do not completely understand where the shared printer processes the requests that are sent to it. I thought that everything was going through the server’s print queue.

I am also looking into an Airport Express. Perhaps I can connect a speaker to one and trigger sounds via AppleScript from multiple computers.

Thanks Adam, the script works great but we are having a few problems because it plays the same beep whenever any of the printers print.

Is there a way to modify this script so that it will play a specific sound only when a specific printer prints?

Is there a way to make an AppleScript trigger like this run even when the user is logged out?

Run this little script:


tell application "Printer Setup Utility" to set P to name of every printer

You will see the printers like this (mine): {“hp LaserJet 1012”, “Stylus COLOR 740”}. Choose the one you mean to have beeps for, and change your on idle script to this:


on idle
	tell application "Printer Setup Utility"
		if status of printer "PutPrinterNameHereInQuotes" is printing then beep 2
		return 2
	end tell
end idle

Thanks again Adam.

More than welcome - learned something myself.


on idle
	tell application "Printer Setup Utility"
		if status of printer "Cold Side Back" is printing then beep 2
		return 2
	end tell
end idle 

I get the following error when I try to run this script:

“NSReceiverEvaluationScriptError: 4”

First, I assume that “Cold Side Back” was the name returned by the Printer Setup Utility, when you asked for the name of every printer . Weird, because printers normally respond with something rather more generic. The reason I asked for what the Print Setup Utility called it, is because that’s “who” you’re asking. Is that the case?

Alternatively, your system considers the print server to be the printer. How do you direct print service to a particular printer?