TASK
When user print the document ,pause the pop will appear then fill the form click enter the form will closed and job has been r
WMI is too slow for this. You probably need to use FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification.
You might find these examples useful.
Finally, I've found a solution on MSDN official documentation website for controlling printer, here is the link: https://www.codeproject.com/Articles/6592/A-Simple-Approach-for-Controlling-Print-Jobs-using
It shows that how to Pause
, Resume
and Delete
a print job. The core class is Win32_PrintJob
.
The variable of printJob
is from ManagementObjectSearcher
object which searched one printer instance.
printJob.InvokeMethod("Pause", null);
printJob.InvokeMethod("Resume", null);
printJob.Delete()
I still found that its Python implementation of code : http://timgolden.me.uk/python/wmi/cookbook.html#watch-for-new-print-jobs
import wmi
c = wmi.WMI ()
print_job_watcher = c.Win32_PrintJob.watch_for (
notification_type="Creation",
delay_secs=1
)
while 1:
pj = print_job_watcher ()
print "User %s has submitted %d pages to printer %s" % \
(pj.Owner, pj.TotalPages, pj.Name)