Jump to content

Print statistics


Recommended Posts

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

Some questions that come to mind:

  • Is it a local attached or network printer
  • What brand/type do you use
  • Is 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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Some questions that come to mind:

  • Is it a local attached or network printer
  • What brand/type do you use
  • Is the printer SNMP enabled (so you can use the printers statistics)

1. It is a local printer which doesn't share with other PC

2. 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 much

Chris YEUNG

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 by 99ojo
Link to comment
Share on other sites

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

To water: Thank you for your quick response, I've run the class but cant find needed information

To 99ojo: Thanks. I just ran the .au3 by declaring some variables without the included. No problem

I 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

To water: Thank you for your quick response, I've run the class but cant find needed information

To 99ojo: Thanks. I just ran the .au3 by declaring some variables without the included. No problem

I 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 report

1) A document is printed.

2) Several documets are printed

3) What does the WMI report generate, after the documents were printed and print spool is empty

4) 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 by 99ojo
Link to comment
Share on other sites

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 by zeroman
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...