新手求助 "请求动作失败(请求于对象)"
调用大漠插件里的找图功能老是不成功,大哥们帮忙看看那出错了Run("\regsvr32 c:\test\plugin\dm.dll /s")
Sleep(2000)
Dim $x,$y
$dm = ObjCreate("dm.dmsoft")
$pos = _FindPic(0,0,1339,899,"1.bmp","000000",0.9,0)
Func _FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $delta,$fSimilar,$dr)
;MsgBox(0, "$szFileName 的值为:", $szFileName)
;MsgBox(0, "$delta 的值为:", $delta)
Dim $pos
$foundpixel = $dm.FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $delta,$fSimilar,$dr,$x,$y)
$pos = $x
$pos = $y
Return $pos
EndFunc ;==>FindPic 修改这句试试:
Run("\regsvr32 c:\test\plugin\dm.dll /s")
Sleep(2000)
改为:
RunWait("regsvr32 /s c:\test\plugin\dm.dll")
或改为:
$sDll = "c:\test\plugin\dm.dll"
_RegisterServer($sDll)
Func _RegisterServer($sDll)
Local $fInit, $fError
Local $aCall = DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0)
If Not @error Then $fInit = $aCall <> 1 ; The COM library is already initialized
$aCall = DllCall($sDll, "long", "DllRegisterServer")
If @error Then $fError = True
If $fInit Then DllCall("ole32.dll", "none", "OleUninitialize")
If $fError Then Return SetError(2, 0, False)
Return SetError($aCall <> 0, $aCall, $aCall = 0)
EndFunc 插件的鼠标和键盘都可以正常使用,我就是怀疑FindPic的返回值的接收有问题
long FindPic(x1, y1, x2, y2, pic_name, delta_color,sim, dir,intX, intY)
x1:区域的左上X坐标
y1:区域的左上Y坐标
x2:区域的右下X坐标
y2:区域的右下Y坐标
pic_name:图片名,可以是多个图片,比如"test.bmp|test2.bmp|test3.bmp"
delta_color:颜色色偏 比如"203040" 表示RGB的色偏分别是20 30 40 (这里是16进制表示)
sim:相似度,取值范围0.1-1.0
dir:查找方向 0: 从左到右,从上到下 1: 从左到右,从下到上 2: 从右到左,从上到下 3: 从右到左, 从下到上
intX:返回图片左上角的X坐标
intY:返回图片左上角的Y坐标
返回值:
返回找到的图片的序号,从0开始索引.如果没找到返回-1
示例:
dm_ret = dm.FindPic(0,0,2000,2000,"1.bmp|2.bmp|3.bmp","000000",0.9,0,intX,intY)
If intX >= 0 and intY >= 0 Then
MessageBox "找到" 用论坛的UDF实现了找功能
Run("\regsvr32 C:\WINDOWS\system32\QMDispatch.dll /s")
Run("\regsvr32 C:\test\plugin\dm.dll /s")
Sleep(2000)
$obj = ObjCreate("QMDispatch.QMFunction")
Dim $pos
Dim $x,$y
Sleep(2000)
$dm = ObjCreate("dm.dmsoft")
$pos = _FindPic(0, 0, 1023, 767, "C:\test\1.bmp",0.5)
MouseMove($pos, $pos)
Func _FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $fSimilar)
$foundpixel = $obj.FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $fSimilar)
MsgBox(0, "$foundpixel 的值为:", $foundpixel)
$pos = Int($foundpixel / 8192)
$pos = Mod($foundpixel, 8192)
Return $pos
EndFunc ;==>FindPic 用ole查看findpic问题应该是出在返回类型上了
long FindPic(
long x1,
long y1,
long x2,
long y2,
BSTR pic_name,
BSTR delta_color,
double sim,
long dir,
VARIANT* x,
VARIANT* y); 用ole查看findpic问题应该是出在返回类型上了
long FindPic(
long x1,
long y1,
long x2,
long y2,
BSTR pic_name,
BSTR delta_color,
double sim,
long dir,
VARIANT* x,
VARIANT* y); 回复 5# fkeipkr
我也觉得是这样,但我也找不到办法解决,现在你解决了吧? {:face (52):}还没有解决
页:
[1]