Python win32print 打印机状态混乱 [英] Python win32print printer status confusion

查看:102
本文介绍了Python win32print 打印机状态混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 Python 的 win32print 模块来尝试获取有关打印机组的各种信息,例如驱动程序名称、作业计数、正在使用的端口、状态等.它大多是成功的,但是我在使用 win32print 返回的状态代码时遇到了很多麻烦API.

I've been using the win32print module for Python to try to get various information about sets of printers, such as driver name, job count, port being used, status, etc. It's been mostly successful, however I am having a lot of trouble making any use of the status code that win32print returns from the API.

我一直在使用 win32print.GetPrinter 方法,它返回一个 PRINTER_INFO_ 字典,其中一个映射是状态.但是,没有记录什么状态代码对应于什么打印机状态.似乎 0 是空闲的,1 是暂停的,但除此之外我不确定它是什么意思.

I've been using the win32print.GetPrinter method, which returns a PRINTER_INFO_ dictionary, with one mapping being Status. However, it isn't documented what status code corresponds to what printer status. It seems that 0 is idle, 1 is paused, but other than that I'm not sure what it means.

当我查找 windows 32bit API 的常量值时,我发现 这个页面,但我收到的状态代码似乎都没有匹配.很多时候,我得到一个像 1052800 这样的状态代码(从 Epson 打印机得到的),它不在 win32api 常量的列表中.

When I looked up values of constants for the windows 32bit API, I found this page, but none of the status codes I ever get back seem to match that. Often times, I get a status code like 1052800 (got that one from an Epson printer), which is not on the list from the win32api constants.

我也尝试过使用 WMI 模块来做到这一点,但成功率更低.

I have also tried using WMI modules to do this with even less success.

我想获取打印机缺纸、打印机门打开、碳粉不足、卡纸等的打印机状态代码.有没有人有任何关于在哪里可以找到这些状态代码含义的提示,或者甚至更好的解决方案完全找到打印机状态?

I would like to get printer status codes for printer out of paper, printer door open, toner low, paper jam, etc. Does anyone have any tips on where to find what these status codes mean, or even a better solution to finding printer status completely?

推荐答案

返回的状态是位掩码,描述例如 此处.多个值可以组合在一起,因此您的值 1052800(十六进制 0x101080)表示打印机具有(所有)状态;

The status returned is a bitmask, which is described for example here. Multiple values can be ORed together, so your value 1052800 (hex 0x101080) means the printer has (all of the) statuses;

  • PRINTER_STATUS_USER_INTERVENTION
  • PRINTER_STATUS_NOT_AVAILABLE
  • PRINTER_STATUS_OFFLINE

这篇关于Python win32print 打印机状态混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆