当前位置:文档之家› VB调用大漠dll的3种方法! 回复有源码 有vb例子(解决占CPU高的问题)

VB调用大漠dll的3种方法! 回复有源码 有vb例子(解决占CPU高的问题)


================================================================================
'https://www.doczj.com/doc/db13094296.html,/forum.php?mod=viewthread&tid=118820&extra=page%3D1
'大漠dll下载地址
'1 大漠用VB dm = CreateObject(dm.dmsoft)
'引用里 选上dm.dll

Private Sub Command1_Click()
Dim dm As Object
Dim ver
Set dm = CreateObject("dm.dmsoft")
ver = dm.ver()
If Len(ver) = 0 Then
MsgBox "当前大漠插件未能正常调用"
Else
MsgBox "当前大漠插件DM.dll版本是:" & ver
End If
End Sub

' 第一种方法奇卡 cpu 占用高

'================================================================================

'2 '在VB6里面新建一个对象:dmsoft对象

' 引用里 选上dm.dll
' 通用里 新建一个 dmsoft对象

'其他插件也可以这样调用 Dim b As New dmsoft 只需要把dmsoft 换成别的插件的类名

Dim b As New dmsoft

'在VB6里面新建一个对象:dmsoft对象
Private Sub Command1_Click()
本帖隐藏的内容
b.SetWindowText Me.hWnd, "你好" '修改VB的窗口标题

b.MoveTo 100, 100
End Sub
Private Sub Command2_Click()
jb = b.GetForegroundWindow()
MsgBox jb
End Sub
Private Sub Command3_Click()
Form1.Caption = "找图"
'dm.FindPic 0, 0, 800, 600, App.Path + "\开始.bmp", 0, 0.9, 0, X, y
Call b.FindPic(0, 0, 800, 600, "C:\开始.bmp", 0, 0.9, 0, x, y)
If x >= 0 Then
b.MoveTo x, y '移动鼠标
'dm.LeftClick '移动单击
MsgBox "找图找到!"
Else
MsgBox "找图没找到!"
End If
End Sub



'================================================================================

'3 建立个模块

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'延时函数 sleep
Public Function Delay(DT As Long)
For i = 0 To DT Step 2
DoEvents '操作权交给系统 否则程序会暂时无响应
Sleep 1
Next i
End Function
Public Function 注册(dm As Object) As Object
Shell "regsvr32 dm.dll /s" '注册大漠插件到系统
Delay 500
Set dm = CreateObject("dm.dmsoft") '创建大漠插件
End Function

'窗体
Dim dm As Object '声明 DM 为控件类型


Private Sub 句柄_Click()
Dim jb As Long
jb = dm.GetForegroundWindow()
MsgBox "句柄是:" & jb
End Sub
Private Sub 版本_Click()
Form1.Caption = "版本"
ver = dm.ver()
If Len(ver) = 0 Then
MsgBox "当前大漠插件未能正常调用"
Else
MsgBox "当前大漠插件DM.dll版本是:" & ver
End If
End Sub

Private Sub 退出_Click()
End
End Sub
Private Sub 移动_Click()
Form1.Caption = "移动鼠标"

dm.MoveTo 22, 22 '移动鼠标
'dm_ret = dm.LeftClick '移动单击
End Sub
Private Sub 找图_Click()
Form1.Caption = "找图"
'dm.FindPic 0, 0, 800, 600, App.Path + "\开始.bmp", 0, 0.9, 0, X, y
Call dm.FindPic(0, 0, 800, 600, App.Path + "\开始.bmp", 0, 0.9, 0, X, y)
If X >= 0 Then
dm.MoveTo X, y '移动鼠标
'dm.LeftClick '移动单击
Delay 3000
MsgBox "找图找到!"
E

lse
MsgBox "找图没找到!"
End If
End Sub
Private Sub 文字识别_Click()
Form1.Caption = "文字识别"
dm.SetDict 0, App.Path + "\DDDD.txt"
s = dm.Ocr(0, 0, 200, 100, "ffffff-000000", 1#)
MsgBox "识别结果是:" & s
End Sub
Private Sub 找字_Click()
Form1.Caption = "找字"
dm.SetDict 0, App.Path + "\DDDD.txt"
dm_ret = dm.FindStr(0, 0, 200, 100, "我", "ffffff-000000", 1#, intx, intY)
If intx >= 0 Then
dm.MoveTo intx, intY
MsgBox "找字找到!"
Else
MsgBox "找字没找到!"
End If
End Sub
Private Sub Form_Load()
On Error Resume Next '容错处理 遇到错误直接执行下面的语句
注册 dm


End Sub



相关主题
文本预览
相关文档 最新文档