zeroman Posted July 15, 2009 Share Posted July 15, 2009 Hi guys,AutoIt is pretty good for developing self-use program.I would like to write a program which counts the print job that the computer execute everyday. And the data should be recorded in a text file. How could I monitor the printer (the only one) for the number of printing per day??Thank you for your kindly response.Chris YEUNG Link to comment Share on other sites More sharing options...
water Posted July 15, 2009 Share Posted July 15, 2009 Some questions that come to mind:Is it a local attached or network printerWhat brand/type do you useIs the printer SNMP enabled (so you can use the printers statistics) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
zeroman Posted July 15, 2009 Author Share Posted July 15, 2009 Some questions that come to mind:Is it a local attached or network printerWhat brand/type do you useIs the printer SNMP enabled (so you can use the printers statistics)1. It is a local printer which doesn't share with other PC2. It is a thermo receipt printer (EPSON EU-T400)3. I'm sorry that I don't know what is SNMP. How can I check the SNMP is enabled? If it is enabled, how can I get the statistics information?Thank you very muchChris YEUNG Link to comment Share on other sites More sharing options...
water Posted July 15, 2009 Share Posted July 15, 2009 Thanks for the additional information. I have no local printer to test, but I think using WMI you could extract some of the needed information. Could you please download Scriptomatic and hava a look at the Win32_Printer WMI Class (see attachement). The code generated by Scriptomatic is pure Autoit so you can copy&paste the required parts to your script. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
99ojo Posted July 15, 2009 Share Posted July 15, 2009 (edited) Thanks for the additional information. I have no local printer to test, but I think using WMI you could extract some of the needed information. Could you please download Scriptomatic and hava a look at the Win32_Printer WMI Class (see attachement). The code generated by Scriptomatic is pure Autoit so you can copy&paste the required parts to your script.Hi,there is a missing include in scriptomatic.au3 for AutoIT 3.3.0.0:#include <WindowsConstants.au3>@zeroman: What do you mean: And the data should be recorded in a text file.The data of the print job? or just the name of the printjob e.g. FP00000.SPL;-))Stefan Edited July 15, 2009 by 99ojo Link to comment Share on other sites More sharing options...
zeroman Posted July 15, 2009 Author Share Posted July 15, 2009 Hi,there is a missing include in scriptomatic.au3 for AutoIT 3.3.0.0:#include <WindowsConstants.au3>@zeroman: What do you mean: And the data should be recorded in a text file.The data of the print job? or just the name of the printjob e.g. FP00000.SPL;-))StefanTo water: Thank you for your quick response, I've run the class but cant find needed informationTo 99ojo: Thanks. I just ran the .au3 by declaring some variables without the included. No problemI just want to show the number of printing(or print job?) per day. And save the numbers into a text file only. Not the information about print jobs. Link to comment Share on other sites More sharing options...
99ojo Posted July 15, 2009 Share Posted July 15, 2009 (edited) To water: Thank you for your quick response, I've run the class but cant find needed informationTo 99ojo: Thanks. I just ran the .au3 by declaring some variables without the included. No problemI just want to show the number of printing(or print job?) per day. And save the numbers into a text file only. Not the information about print jobs.Hi,have a look at WMI Class WIN32_PrintJob. You have to test, what is happening with the WMI report1) A document is printed.2) Several documets are printed3) What does the WMI report generate, after the documents were printed and print spool is empty4) What does the report do, if you print a new document after step 3)Maybe another solution is, to monitor spool directory for files and compare the file attributes (date, size etc.) and plot an internal counter to a text file.;-))Stefan Edited July 15, 2009 by 99ojo Link to comment Share on other sites More sharing options...
zeroman Posted July 17, 2009 Author Share Posted July 17, 2009 (edited) I think this should OK. Anyone can test it for me in a local OR network OR multiple printers? HotKeySet("{ESC}", "_Quit") $counter = 0 $intPreID = 0 while 1 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objItem.JobID <> $intPreID Then ConsoleWrite("JobId: " & $objItem.JobId & @CRLF) $counter = $counter + 1 MsgBox(1,"",$counter) $intPreID = $objItem.JobID EndIf Next EndIf WEnd Func _Quit() Exit EndFunc ;==>_Quit Edited July 17, 2009 by zeroman Link to comment Share on other sites More sharing options...
99ojo Posted July 17, 2009 Share Posted July 17, 2009 I think this should OK. Anyone can test it for me in a local OR network OR multiple printers? HotKeySet("{ESC}", "_Quit") $counter = 0 $intPreID = 0 while 1 $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PrintJob", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If $objItem.JobID <> $intPreID Then ConsoleWrite("JobId: " & $objItem.JobId & @CRLF) $counter = $counter + 1 MsgBox(1,"",$counter) $intPreID = $objItem.JobID EndIf Next EndIf WEnd Func _Quit() Exit EndFunc ;==>_Quit Hi, for decrease cpu-usage just insert at minimum a sleep (20) before the WEND. Otherwise you would have CPU usage 100 % all the time. ;-)) Stefan Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now