Sign in to follow this  
Followers 0
masvil

Print detection

7 posts in this topic

How can I detect if printer is printing a file?

Share this post


Link to post
Share on other sites



How can I detect if printer is printing a file?

something like this:

$intPrinters = 1

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")

For $objItem In $colItems
    MsgBox(0,"Printer Info","Printers on " _
             & $objItem.name & ", Printer Number: " & $intPrinters & @LF & _ 
            "====================================" & @LF & _ 
            "Availability: " & $objItem.Availability & @LF & _
            "Description: " & $objItem.Description & @LF & _ 
            "Printer: " & $objItem.DeviceID & @LF & _ 
            "Driver Name: " & $objItem.DriverName & @LF & _ 
            "Port Name: " & $objItem.PortName & @LF & _ 
            "Printer State: " & $objItem.PrinterState & @LF & _ 
            "Printer Status: " & $objItem.PrinterStatus & @LF & _ 
            "PrintJobDataType: " & $objItem.PrintJobDataType & @LF & _ 
            "Print Processor: " & $objItem.PrintProcessor & @LF & _ 
            "Spool Enabled: " & $objItem.SpoolEnabled & @LF & _ 
            "Separator File: " & $objItem.SeparatorFile & @LF & _ 
            "Queued: " & $objItem.Queued & @LF & _ 
            "Status: " & $objItem.Status & @LF & _ 
            "StatusInfo: " & $objItem.StatusInfo & @LF & _ 
            "Published: " & $objItem.Published & @LF & _ 
            "Shared: " & $objItem.Shared & @LF & _ 
            "ShareName: " & $objItem.ShareName & @LF & _ 
            "Direct: " & $objItem.Direct & @LF & _ 
            "Location: " & $objItem.Location & @LF & _ 
            "Priority: " & $objItem.Priority & @LF & _ 
            "Work Offline: " & $objItem.WorkOffline & @LF & _ 
            "Horizontal Res: " & $objItem.HorizontalResolution & @LF & _
            "Vertical Res: " & $objItem.VerticalResolution )
    $intPrinters = $intPrinters + 1
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

"Printer State: " & $objItem.PrinterState & @LF & _

Good, Thanx. When printer is printing then it go from 3 to 4. Any way to see the filename?

Edited by masvil

Share this post


Link to post
Share on other sites

i'm working on it

to see the filename, you need to retrieve information about jobs of the printer

i have integrated this function in my admin tool

let's take a look when i will publish it


-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
$colInstalledPrinters =  $objWMIService.ExecQuery("Select * from Win32_PrintJob Where Document <> ''")

MsgBox(262144,'Debug line ~38','Selection:' & @lf & '$colInstalledPrinters' & @lf & @lf & 'Return:' & @lf & $colInstalledPrinters & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX

For $objPrinter in $colInstalledPrinters
    MsgBox(0,'',$objPrinter.Document)
Next

When this is ran and no documents are printing what does the $colInstalledPrinters consist of? I want to make is so that it will alert the user that nothing is in process. By the way this is my first time doing anything like this..... Could some of this be wrote better?

Edited by strate

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites

Nobody... Is it an array?


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
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
Sign in to follow this  
Followers 0