找回密码
 加入
搜索
查看: 4390|回复: 10

[系统综合] 操作打印机的问题

  [复制链接]
发表于 2011-1-3 18:42:49 | 显示全部楼层 |阅读模式
有没有操作打印机的示例呀

指定打印机端口USB001

检查打印机是否联机

检查打印机是否被暂停了

只要这几个简单的示例就好了!!!
 楼主| 发表于 2011-1-4 12:28:48 | 显示全部楼层
有没有人会知道哦~~~
发表于 2011-1-6 13:26:25 | 显示全部楼层
一般会调用第三方EXE或DLL,功能较全面。

官方论坛见过有一个相关的UDF,可以自己搜搜。
 楼主| 发表于 2011-1-6 15:13:04 | 显示全部楼层
回复 3# kodin


    有搜过,搜不到哦~~~
发表于 2011-1-7 08:22:25 | 显示全部楼层
官网有个UDF,不知道是不是楼主要找的那个?
原贴地址:(没钱的,路过的,请看下面的代码:)
http://www.autoitscript.com/foru ... arch__1#entry852981

原文描述如下:
This is a printing UDF which allows you to print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images. Useful for labels, reports, graphs and standard forms. Can also print barcodes. It uses my printmg.dll. It is not intended to do the sorts of thing you can do with the Word UDF by big_daddy.
Note the dll is 32 bit and so only works with 32 bit applications.

附件如下:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2011-1-9 16:30:41 | 显示全部楼层
额,这也收费呀~~~啊啊。。。下载下来看下哦。
 楼主| 发表于 2011-1-9 16:57:14 | 显示全部楼层
回复 5# kingfirekkk


    不行哦。这个UDF是操作打印的样式什么之类的,我要的是想可以设置 打印机一些参数的UDF哦。
发表于 2011-1-9 22:49:24 | 显示全部楼层
很好,刚好有用。
 楼主| 发表于 2011-1-10 13:19:44 | 显示全部楼层
额,不好用呀。
发表于 2011-1-14 08:22:22 | 显示全部楼层
以下代码供参考,可实现楼主需要的部分功能:
$intPrinters = 1

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

For $objItem In $colItems
    if $objItem.Queued > 0 or $objItem.PrinterStatus <> 3 or $objItem.PrinterState <> 0 Then
    ConsoleWrite("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 )
    ConsoleWrite(@lf & "************************************************************************************" & @lf)
    EndIf
    $intPrinters = $intPrinters + 1
Next

执行结果如下:

Printer: \\IP\HP LaserJet P1007    
Driver Name: HP LaserJet P1007
Port Name: USB001   ; (端口名,可获取后进行选择)
Printer State: 16          
Printer Status: 1          ;(1为联机,其它的状态可能要自己找WMI的资料看看了。。)
PrintJobDataType: RAW
Print Processor: HP1006S
Spool Enabled: True
Separator File: 
Queued: False
Status: Error
StatusInfo: 
Published: False
Shared: True
ShareName: HPLaserJ
Direct: False
Location: 
Priority: 1
Work Offline: False       ;(打印机是否在线)
Horizontal Res: 600
Vertical Res: 600
************************************************************************************
 楼主| 发表于 2011-1-14 09:06:20 | 显示全部楼层
回复 10# kingfirekkk


    谢谢!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 15:38 , Processed in 0.076358 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表