注册大漠插件
- 注册dm.dll
- 管理员运行命令提示符
- 执行Regsvr32 d:\dmcj\dm.dll
- 64位系统修改注册表,让VBS能调用DMCJ
- regedit
- HKCR\VBSFile\Shell\Open\Command
- 将"%SystemRoot%\System32\WScript.exe" "%1" %*
- 修改成"%SystemRoot%\SysWow64\WScript.exe" "%1" %*
- 测试代码,
Set dm = CreateObject("dm.dmsoft")
ver = dm.Ver()
msgbox ver
VBS操作大漠插件抓取网页数据
Set dm = CreateObject("dm.dmsoft")
dm_ret=dm.SetDict(0,"D:\DMCJ\dm_soft.txt")
'注册dm以及字库位置确认
riqi = now()
Set ie=WScript.CreateObject("internetexplorer.application")
ie.menubar=0 '不显示IE对象菜单栏
ie.AddressBar=0 '不显示IE对象地址栏
ie.ToolBar=0 '不显示IE对象工具栏
ie.StatusBar=0 '不显示IE对象状态栏
ie.FullScreen= 0 '全屏化IE对象
ie.Width=800 '设置IE对象宽度
ie.Height=800 '设置IE对象高度
ie.Resizable=0 '设置IE对象大小是否可以被改动
ie.visible=1 '设置是否可见
ie.Navigate "192.168.0.3" '设置IE对象默认指向的页面
'设置打开IE,并初始化窗口参数
'绑定窗口句柄
hwnd = dm.FindWindow("","Internet")
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
WScript.Sleep 200
if dm_ret<>1 then
msgbox "窗口绑定没成功,程序结束"
wscript.quit
end if
'激活账号密码输入框
dm.MoveTo 350,330
WScript.Sleep 200
dm.LeftClick
'输入用户名
WScript.Sleep 200
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 9
'输入密码
dm.KeyPress 88
dm.KeyPress 189
dm.KeyPress 65
dm.KeyPress 68
dm.KeyPress 77
dm.KeyPress 73
dm.KeyPress 78
dm.KeyPress 13
'对弹出的确认窗口进行操作
WScript.Sleep 200
dm.KeyPress 13
WScript.Sleep 200
dm.KeyPress 13
dm.UnBindWindow()
WScript.Sleep 300
hwnd = dm.FindWindow("","Internet")
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
'识别消耗品三个字并点击
Do
dm_ret = dm.FindStrFast(19,207,77,229,"消耗品","333333-000000",1.0,intX,intY)
WScript.Sleep 300
Loop Until dm_ret = 0
dm.moveto intx+10,inty+10
dm.LeftClick
WScript.Sleep 1000
'识别(K)黑色
b1=dm.Ocr(293,259,373,283,"b@e3e7f1-000000",1.0)
z1=dm.Ocr(459,257,512,282,"b@e3e7f1-000000",1.0)
y1=dm.Ocr(565,263,606,278,"b@e3e7f1-000000",1.0)
'识别(C)青色
b2=dm.Ocr(292,293,372,310,"b@e3e7f1-000000",1.0)
z2=dm.Ocr(466,290,508,313,"b@e3e7f1-000000",1.0)
y2=dm.Ocr(567,287,605,316,"b@e3e7f1-000000",1.0)
'识别(M)洋红
b3=dm.Ocr(291,325,394,344,"b@e3e7f1-000000",1.0)
z3=dm.Ocr(465,324,513,344,"b@e3e7f1-000000",1.0)
y3=dm.Ocr(560,321,607,346,"b@e3e7f1-000000",1.0)
'识别(Y)黄色
b4=dm.Ocr(292,352,385,378,"b@e3e7f1-000000",1.0)
z4=dm.Ocr(466,356,506,375,"b@e3e7f1-000000",1.0)
y4=dm.Ocr(561,352,607,378,"b@e3e7f1-000000",1.0)
'识别废粉盒
b5=dm.Ocr(292,455,353,478,"b@e3e7f1-000000",1.0)
z5=dm.Ocr(466,454,522,479,"b@e3e7f1-000000",1.0)
'识别黑色感光鼓
b6=dm.Ocr(292,554,368,577,"b@e3e7f1-000000",1.0)
z6=dm.Ocr(469,554,517,580,"b@e3e7f1-000000",1.0)
'识别青色感光鼓
b7=dm.Ocr(292,582,374,612,"b@e3e7f1-000000",1.0)
z7=dm.Ocr(471,580,516,608,"b@e3e7f1-000000",1.0)
'识别红色感光鼓
b8=dm.Ocr(293,614,388,640,"b@e3e7f1-000000",1.0)
z8=dm.Ocr(471,617,516,638,"b@e3e7f1-000000",1.0)
'识别黄色感光鼓
b9=dm.Ocr(294,646,367,662,"b@e3e7f1-000000",1.0)
z9=dm.Ocr(468,645,517,663,"b@e3e7f1-000000",1.0)
ie.Navigate "192.168.0.5" '设置IE对象默认指向的页面
Set fso=CreateObject("Scripting.FileSystemObject")
yn=fso.FileExists("./耗材使用情况.txt")
if yn = 0 then
set txtfile=fso.createtextfile("./耗材使用情况.txt",ture)
end if
Set txtfile=fso.opentextfile("./耗材使用情况.txt",8)
txtfile.writeline riqi&" 3375 "&b1&" 状态:"&z1&" 余量:"&y1
txtfile.writeline riqi&" 3375 "&b2&" 状态:"&z2&" 余量:"&y2
txtfile.writeline riqi&" 3375 "&b3&" 状态:"&z3&" 余量:"&y3
txtfile.writeline riqi&" 3375 "&b4&" 状态:"&z4&" 余量:"&y4
txtfile.writeline chr(10)
txtfile.writeline riqi&" 3375 "&b5&" 状态:"&z5
txtfile.writeline riqi&" 3375 "&b6&" 状态:"&z6
txtfile.writeline riqi&" 3375 "&b7&" 状态:"&z7
txtfile.writeline riqi&" 3375 "&b8&" 状态:"&z8
txtfile.writeline riqi&" 3375 "&b9&" 状态:"&z9
txtfile.writeline chr(10)
txtfile.close
WScript.Sleep 1500
dm.KeyDown 17
WScript.Sleep 200
dm.KeyPress 87
WScript.Sleep 200
dm.KeyUp 17
WScript.Sleep 200
dm.UnBindWindow()
'绑定窗口句柄
hwnd = dm.FindWindow("","Internet")
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
WScript.Sleep 200
if dm_ret<>1 then
msgbox "窗口绑定没成功,程序自动结束"
wscript.quit
end if
'激活账号密码输入框
dm.MoveTo 350,330
WScript.Sleep 200
dm.LeftClick
'输入用户名
WScript.Sleep 200
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 49
dm.KeyPress 9
'输入密码
dm.KeyPress 88
dm.KeyPress 189
dm.KeyPress 65
dm.KeyPress 68
dm.KeyPress 77
dm.KeyPress 73
dm.KeyPress 78
dm.KeyPress 13
'对弹出的确认窗口进行操作
WScript.Sleep 200
dm.KeyPress 13
WScript.Sleep 200
dm.KeyPress 13
dm.UnBindWindow()
WScript.Sleep 300
hwnd = dm.FindWindow("","Internet")
dm_ret = dm.BindWindow(hwnd,"normal","normal","normal",0)
'识别消耗品三个字并点击
Do
dm_ret = dm.FindStrFast(19,207,77,229,"消耗品","333333-000000",1.0,intX,intY)
WScript.Sleep 300
Loop Until dm_ret = 0
dm.moveto intx+10,inty+10
dm.LeftClick
WScript.Sleep 1000
'识别(K)黑色
b1=dm.Ocr(291,255,422,280,"b@e3e7f1-000000",1.0)
z1=dm.Ocr(478,258,643,283,"b@e3e7f1-000000",1.0)
y1=dm.Ocr(643,258,704,279,"b@e3e7f1-000000",1.0)
'识别(C)青色
b2=dm.Ocr(290,286,402,316,"b@e3e7f1-000000",1.0)
z2=dm.Ocr(492,289,636,313,"b@e3e7f1-000000",1.0)
y2=dm.Ocr(651,285,704,314,"b@e3e7f1-000000",1.0)
'识别(M)洋红
b3=dm.Ocr(293,317,400,348,"b@e3e7f1-000000",1.0)
z3=dm.Ocr(493,318,655,346,"b@e3e7f1-000000",1.0)
y3=dm.Ocr(653,321,706,343,"b@e3e7f1-000000",1.0)
'识别(Y)黄色
b4=dm.Ocr(291,349,420,379,"b@e3e7f1-000000",1.0)
z4=dm.Ocr(504,351,642,378,"b@e3e7f1-000000",1.0)
y4=dm.Ocr(662,353,706,377,"b@e3e7f1-000000",1.0)
'识别废粉盒
b5=dm.Ocr(292,451,388,480,"b@e3e7f1-000000",1.0)
z5=dm.Ocr(490,453,591,480,"b@e3e7f1-000000",1.0)
'识别黑色感光鼓
b6=dm.Ocr(290,553,404,584,"b@e3e7f1-000000",1.0)
z6=dm.Ocr(491,549,576,578,"b@e3e7f1-000000",1.0)
'识别青色感光鼓
b7=dm.Ocr(292,582,385,612,"b@e3e7f1-000000",1.0)
z7=dm.Ocr(487,577,594,610,"b@e3e7f1-000000",1.0)
'识别红色感光鼓
b8=dm.Ocr(292,607,412,642,"b@e3e7f1-000000",1.0)
z8=dm.Ocr(489,611,582,640,"b@e3e7f1-000000",1.0)
'识别黄色感光鼓
b9=dm.Ocr(287,639,389,674,"b@e3e7f1-000000",1.0)
z9=dm.Ocr(486,642,581,667,"b@e3e7f1-000000",1.0)
Set txtfile=fso.opentextfile("./耗材使用情况.txt",8)
txtfile.writeline riqi&" 3373 "&b1&" 状态:"&z1&" 余量:"&y1
txtfile.writeline riqi&" 3373 "&b2&" 状态:"&z2&" 余量:"&y2
txtfile.writeline riqi&" 3373 "&b3&" 状态:"&z3&" 余量:"&y3
txtfile.writeline riqi&" 3373 "&b4&" 状态:"&z4&" 余量:"&y4
txtfile.writeline chr(10)
txtfile.writeline riqi&" 3373 "&b5&" 状态:"&z5
txtfile.writeline riqi&" 3373 "&b6&" 状态:"&z6
txtfile.writeline riqi&" 3373 "&b7&" 状态:"&z7
txtfile.writeline riqi&" 3373 "&b8&" 状态:"&z8
txtfile.writeline riqi&" 3373 "&b9&" 状态:"&z9
txtfile.writeline chr(10)
txtfile.close
dm.KeyDown 17
WScript.Sleep 200
dm.KeyPress 87
WScript.Sleep 200
dm.KeyUp 17
WScript.Sleep 200
dm.UnBindWindow()
msgbox "程序运行结束"
wscript.quit
网友评论