Jump to content

Detecting print jobs


tcox8
 Share

Recommended Posts

hey guys, I was wondering if there was any way to use autoit to determine if there is a print job sent to Window's print queue.

What I have are three monitors hooked to one computer. On all three monitors there will be three different print queues to three different printers. When there are no print jobs happening I need there to be three different things going on the monitors(i.e. CNN's headlines on one screen, the weather webpage on another, etc.). That isn't the hard part. However, what I need is when there is a print job detected then that monitor will show the print queue to the printer that received the print job and the other monitors will still show the web pages.

Maybe what I need is a pixelsearch or pixelchecksum that can work for inactive windows? I read that it's possible to do this but I can't figure out how nor can I find any examples of it working in an unactive window.

Any ideas? thanks in advance!

"There are only 10 types of people in the world: Those who understand binary, and those who don't"

Link to comment
Share on other sites

hey guys, I was wondering if there was any way to use autoit to determine if there is a print job sent to Window's print queue.

What I have are three monitors hooked to one computer. On all three monitors there will be three different print queues to three different printers. When there are no print jobs happening I need there to be three different things going on the monitors(i.e. CNN's headlines on one screen, the weather webpage on another, etc.). That isn't the hard part. However, what I need is when there is a print job detected then that monitor will show the print queue to the printer that received the print job and the other monitors will still show the web pages.

Maybe what I need is a pixelsearch or pixelchecksum that can work for inactive windows? I read that it's possible to do this but I can't figure out how nor can I find any examples of it working in an unactive window.

Any ideas? thanks in advance!

One way to find out if there are any print jobs queued for a particular printer is to use the GetPrinter API with the level parameter set to 2. The returned PRINTER_INFO_2 structure has an element which holds the number of print jobs queued for that printer.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

One way to find out if there are any print jobs queued for a particular printer is to use the GetPrinter API with the level parameter set to 2. The returned PRINTER_INFO_2 structure has an element which holds the number of print jobs queued for that printer.

Thanks for your fast reply! I tried your solution however I can't find any documentation on the GetPrinter API in the autoit help file. Is there something else I'm missing?

"There are only 10 types of people in the world: Those who understand binary, and those who don't"

Link to comment
Share on other sites

@tcox8

maybe this can get you going.

Dim $intTotalJobs, $intTotalPages, $intMaxPrintJob

$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$colPrintJobs =  $objWMIService.ExecQuery ("Select * from Win32_PrintJob")

For $objPrintJob in $colPrintJobs 
    $intTotalJobs = $intTotalJobs + 1
    $intTotalPages = $intTotalPages + $objPrintJob.TotalPages
    If $objPrintJob.TotalPages > $intMaxPrintJob Then
        $intMaxPrintJob = $objPrintJob.TotalPages
    EndIf
Next

ConsoleWrite("Total print jobs in queue: " & $intTotalJobs  & @CRLF) 
ConsoleWrite( "Total pages in queue: " & $intTotalPages & @CRLF) 
ConsoleWrite( "Largest print job in queue: " & $intMaxPrintJob & @CRLF)

regards,

ptrex

Link to comment
Share on other sites

@tcox8

maybe this can get you going.

Dim $intTotalJobs, $intTotalPages, $intMaxPrintJob

$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$colPrintJobs =  $objWMIService.ExecQuery ("Select * from Win32_PrintJob")

For $objPrintJob in $colPrintJobs 
    $intTotalJobs = $intTotalJobs + 1
    $intTotalPages = $intTotalPages + $objPrintJob.TotalPages
    If $objPrintJob.TotalPages > $intMaxPrintJob Then
        $intMaxPrintJob = $objPrintJob.TotalPages
    EndIf
Next

ConsoleWrite("Total print jobs in queue: " & $intTotalJobs  & @CRLF) 
ConsoleWrite( "Total pages in queue: " & $intTotalPages & @CRLF) 
ConsoleWrite( "Largest print job in queue: " & $intMaxPrintJob & @CRLF)

regards,

ptrex

Thanks for your replies guys! You help is greatly appreciated :-)

"There are only 10 types of people in the world: Those who understand binary, and those who don't"

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