- Home /
Get notification from command line or other application when a printer finish printng?
Hello! I am working on a game in which people take selfie via webcam and the photo is printed by a printer.
I am using System.Diagnostics.Process to open cmd.exe and pass command into it.
("rundll32 C:\\WINDOWS\\system32\\shimgvw.dll,ImageView_PrintTo " + "\"" + (Path) + "\"" + " " + "\"" + "(Printer Name)" + "\"")
This works and my printer successfully prints photo. However I also want Unity can be able to check whether the printing is done.
After searching and trying I know I can use Prnjobs.vbs or Prncnfg.vbs to know status of printing jobs in command line. ![alt text][1] But I don't konw how to let Unity know the printing status.
Maybe there is some way to save those information as a text file from cmd, and then ask Unity to read it? Or make another small WPF or Windows Form application to check the status (maybe the Win32_Printer class is what I need?) and make it talk to Unity?
I will be really grateful if you can give me some advice. Thank you!
Win32_Printer class https://msdn.microsoft.com/en-us/library/aa394363(v=vs.85).aspx
Answer by qwert024 · Jun 29, 2018 at 01:35 AM
https://stackoverflow.com/questions/1390559/how-to-get-the-output-of-a-system-diagnostics-process
This may do the trick! Run prnjobs.vbs in CMD and use StandardOutput.ReadToEnd() to read the output from CMD
EDIT
I've implemented this and put it on github.