找回密码
 加入
搜索
查看: 4308|回复: 7

[系统综合] 新手求助 "请求动作失败(请求于对象)"

  [复制链接]
发表于 2011-2-9 06:52:09 | 显示全部楼层 |阅读模式
调用大漠插件里的找图功能老是不成功,大哥们帮忙看看那出错了

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[2]
                 $foundpixel = $dm.FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $delta,$fSimilar,$dr,$x,$y)
         $pos[0] = $x  
         $pos[1] = $y
         Return $pos  
EndFunc ;==>FindPic
发表于 2011-2-9 14:03:34 | 显示全部楼层
修改这句试试:
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[0] <> 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] <> 0, $aCall[0], $aCall[0] = 0)
EndFunc
 楼主| 发表于 2011-2-10 03:44:04 | 显示全部楼层
插件的鼠标和键盘都可以正常使用,我就是怀疑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 "找到"
 楼主| 发表于 2011-2-10 04:09:04 | 显示全部楼层
用论坛的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[2]
Dim $x,$y
Sleep(2000)
$dm = ObjCreate("dm.dmsoft")
$pos = _FindPic(0, 0, 1023, 767, "C:\test\1.bmp",0.5)
MouseMove($pos[0], $pos[1])




Func _FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $fSimilar)     
        $foundpixel = $obj.FindPic($iLeft, $iTop, $iRight, $iBottom, $szFileName, $fSimilar)
                MsgBox(0, "$foundpixel 的值为:", $foundpixel)
        $pos[0] = Int($foundpixel / 8192)
        $pos[1] = Mod($foundpixel, 8192)
        Return $pos
EndFunc   ;==>FindPic
 楼主| 发表于 2011-2-10 13:38:50 | 显示全部楼层
用ole查看findpic问题应该是出在返回类型上了
[id(0x00000072)]
long FindPic(
                long x1,
                long y1,
                long x2,
                long y2,
                BSTR pic_name,
                BSTR delta_color,
                double sim,
                long dir,
                VARIANT* x,
                VARIANT* y);
 楼主| 发表于 2011-2-10 13:38:55 | 显示全部楼层
用ole查看findpic问题应该是出在返回类型上了
[id(0x00000072)]
long FindPic(
                long x1,
                long y1,
                long x2,
                long y2,
                BSTR pic_name,
                BSTR delta_color,
                double sim,
                long dir,
                VARIANT* x,
                VARIANT* y);
发表于 2011-3-5 00:31:49 | 显示全部楼层
回复 5# fkeipkr

我也觉得是这样,但我也找不到办法解决,现在你解决了吧?
 楼主| 发表于 2011-3-13 11:46:40 | 显示全部楼层
还没有解决
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

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

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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