AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Printer Options - Rundll32 [CMD]
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Utilities & Resources
View previous topic :: View next topic  
Author Message
superbem



Joined: 30 Jul 2007
Posts: 20

PostPosted: Thu Nov 15, 2007 2:52 pm    Post subject: Reply with quote

Is there a way to know if a printer is out of paper?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2699
Location: Australia, Qld

PostPosted: Fri Nov 16, 2007 1:50 am    Post subject: Reply with quote

Quote:
Is there a way to know if a printer is out of paper?
Possibly, but not via printui.dll.


I thought I'd point out that the text in BoBo's original post can be reproduced (in your current language) by typing this at a command prompt:
Code:
rundll32 printui.dll,PrintUIEntry /?
Wink


Edit: Here's my first attempt at reporting printer status:
Code:
DllCall("LoadLibrary","str","winspool.drv")
if ! DllCall("winspool.drv\OpenPrinterA","str","HP PSC 750xi","uint*",hPrinter,"uint",0)
{
    MsgBox OpenPrinter failed.`nErrorLevel: %ErrorLevel%`nLastError: %A_LastError%
    return
}
DllCall("winspool.drv\GetPrinterA","uint",hPrinter,"uint",2,"uint",0,"uint",0,"uint*",req)
if (A_LastError = 122)
{ ; ERROR_INSUFFICIENT_BUFFER
    VarSetCapacity(pi,req)
    if DllCall("winspool.drv\GetPrinterA","uint",hPrinter,"uint",2,"uint",&pi,"uint",req,"uint*",req)
        Status := NumGet(pi,72)
}
if Status =
    MsgBox GetPrinter failed.`nErrorLevel: %ErrorLevel%`nLastError: %A_LastError%

DllCall("winspool.drv\ClosePrinter","uint",hPrinter)

MsgBox % Status

/*
PRINTER_STATUS_PAUSED            = 0x00000001
PRINTER_STATUS_ERROR             = 0x00000002
PRINTER_STATUS_PENDING_DELETION  = 0x00000004
PRINTER_STATUS_PAPER_JAM         = 0x00000008
PRINTER_STATUS_PAPER_OUT         = 0x00000010
PRINTER_STATUS_MANUAL_FEED       = 0x00000020
PRINTER_STATUS_PAPER_PROBLEM     = 0x00000040
PRINTER_STATUS_OFFLINE           = 0x00000080
PRINTER_STATUS_IO_ACTIVE         = 0x00000100
PRINTER_STATUS_BUSY              = 0x00000200
PRINTER_STATUS_PRINTING          = 0x00000400
PRINTER_STATUS_OUTPUT_BIN_FULL   = 0x00000800
PRINTER_STATUS_NOT_AVAILABLE     = 0x00001000
PRINTER_STATUS_WAITING           = 0x00002000
PRINTER_STATUS_PROCESSING        = 0x00004000
PRINTER_STATUS_INITIALIZING      = 0x00008000
PRINTER_STATUS_WARMING_UP        = 0x00010000
PRINTER_STATUS_TONER_LOW         = 0x00020000
PRINTER_STATUS_NO_TONER          = 0x00040000
PRINTER_STATUS_PAGE_PUNT         = 0x00080000
PRINTER_STATUS_USER_INTERVENTION = 0x00100000
PRINTER_STATUS_OUT_OF_MEMORY     = 0x00200000
PRINTER_STATUS_DOOR_OPEN         = 0x00400000
PRINTER_STATUS_SERVER_UNKNOWN    = 0x00800000
PRINTER_STATUS_POWER_SAVE        = 0x01000000
PRINTER_STATUS_SERVER_OFFLINE    = 0x02000000
PRINTER_STATUS_DRIVER_UPDATE_NEEDED    = 0x04000000
It works... but requires the printer name to be specified, and seems to only report PRINTER_STATUS_ERROR. Rolling Eyes
Microsoft wrote:
Note, however, that the default port monitor for Windows does not usually set more than the PRINTER_STATUS_ERROR bit of a Printer's Status member.
Specifying "uint",0 for the printer name (in OpenPrinter) gets the local print server, but calling GetPrinter on the returned handle seems to always result in ERROR_INVALID_LEVEL.

You might like to try getting the status of the current print job, as described in How to get the status of a printer and a print job.
Back to top
View user's profile Send private message
superbem



Joined: 30 Jul 2007
Posts: 20

PostPosted: Fri Nov 16, 2007 1:43 pm    Post subject: Reply with quote

Thanks, it fits for what I need.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Utilities & Resources All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group