Q语言 我的命令库《通用找图》之前台找图函数源码

2023-05-17,,

'---------------------前台找图F-------------------------------------


Function 找图F(pictname)  //前台找图
    FindPic 0,0,Plugin.Sys.GetScRX - 1,Plugin.Sys.GetScRY - 1, pic_path&pictname,0.9,找图_intX,找图_intY
    If 找图_intx >= 0 and 找图_inty >= 0 Then 
        日志运行内容 = V_当前程序 & "F---------->找到pict:" & pictname
        Call Lib.通.输出日志(日志运行内容):TracePrint 日志运行内容
        找图F=1
    Else 
        日志运行内容 = V_当前程序 & "F未找到pict:" & pictname
        Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
        找图F=0
    End If
End Function

Function 找图点击F(pictname,偏移X,偏移Y)  //前台找到图后点击
    找图点击F=0
    FindPic 0,0,Plugin.Sys.GetScRX - 1,Plugin.Sys.GetScRY - 1, pic_path&pictname,0.9,找图_intX,找图_intY
    If 找图_intX >= 0 Then 
        LockMouse
        SaveMousePos
        MoveTo 找图_intX + cint(偏移X), 找图_intY + cint(偏移Y)
        delay 50    
        LeftClick 1
        RestoreMousePos 
        UnlockMouse 
        日志运行内容 =  V_当前程序&"F---------->点击pict:"&pictname    
        Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
        找图点击F=1
    End If
End Function

Function 找多图F(pictname)
    Dim I,返回值,pict
    找多图F=0
    pict = split(pictname, "|")
    For i = 0 To ubound(pict)
        FindPic 0,0,Plugin.Sys.GetScRX - 1,Plugin.Sys.GetScRY - 1, pic_path&pict(i),0.9,找多图_intX,找多图_intY
        If 找多图_intx >= 0 Then 
            日志运行内容 =  "找到:第" & cstr(i + 1) & "张pict:" & pict(i)
            Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
            找多图F=i+1
            Exit For
        End If
        日志运行内容 =  "未找到第" & cstr(i + 1) & "张pict:"
        Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
    Next
End Function

Function 等图F(pictname)
    日志运行内容 =  "F正在等待pict....:" & pictname
    Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
    等图 = 0
    等图_intX = -1
    等图_intY = -1    
    For 10000
        返回值 = 找图F(pictname)
        If 返回值 > 0 Then 
            日志运行内容 =  V_当前程序&"B----------->等到pict:" & pictname
            Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
            等图_intX = 找图_intX
            等图_intY = 找图_intY            
            等图F=1
            Exit For
        End If
        Delay 500           
    Next
End Function

Function 等图点击F(pictname,偏移X,偏移Y)
    日志运行内容 =  "正在等待点击pict....:" & pictname
    Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
    等图点击=0
    For 100000
        FindPic 0,0,Plugin.Sys.GetScRX - 1,Plugin.Sys.GetScRY - 1,pic_path&pictname,0.9,等图_intX,等图_intY
        If 等图_intX >= 0 Then 
            LockMouse
            SaveMousePos
            MoveTo 等图_intX + cint(偏移X), 等图_intY + cint(偏移Y)
            Delay 50
            LeftClick 1
            RestoreMousePos 
            UnlockMouse 
            日志运行内容 =  V_当前程序&"F------------->点击pict:" & pictname 
            Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
            Delay 50
            等图点击=1
            Exit For
        End If
        Delay 500   
    Next
End Function

Function 等多图F(pictname)
    Dim 返回值
    等多图F=0
    等多图_intX = -1
    等多图_intY = -1
    For 10000
        返回值=找多图F(pictname)
        If 返回值 > 0 Then 
            等多图F = 返回值
            等多图_intX = 找多图_intX
            等多图_intY = 找多图_intY
            日志运行内容 =  "等到多pict:" & 返回值 
            Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
            Exit For
        End If
        日志运行内容 =  "遍历一次,未等到所有pict"
        Call Lib.通用.输出日志(日志运行内容):TracePrint 日志运行内容
        Delay 500  
    Next
End Function

//注:Lib.通用.输出日志(日志运行内容) 此函数在 命令库 《通用》中 以下同
/*

Sub 输出日志(日志内容)
    If V_输出运行日志 = 1 Then 
        Call Plugin.File.WriteFileEx(V_sPath & "脚本日志.txt", Now()& ": "&日志内容)//这边有加上执行该命令相应的系统时间
    End If
End Sub

*/

《Q语言 我的命令库《通用找图》之前台找图函数源码.doc》

下载本文的Word格式文档,以方便收藏与打印。