按键精灵 调用API

在vb-api帮助手册FindWindow的语句
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


调用示例

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
hwnd = findwindow(vbnullstring, "按键精灵")   //这里vbnullstring可以写成0,但是不可以写成“”,这样就找不到窗口句柄了
MessageBox hwnd

 

如何循环找图 查找多图

//先将图片放到附件里
Dim a(3)
a(0)="Attachment:\马1.bmp"
a(1)="Attachment:\马2.bmp"
a(2)="Attachment:\马3.bmp"
a(3)="Attachment:\马4.bmp"
Call 查找图片数组()
EndScript 
Sub 查找图片数组()
For i=0 to 3
        VBSCall FindPic(746,445,799,570,a(i),1,x,y)
        If x>0 and y>0 Then
            MoveTo x+5,y+5
            LeftClick 1
            Exit For
        End If 
next
End Sub


找图及循环查找多个图片

//一般找图
FindPic 0,0,1024,768,"Attachment:\图片名.bmp",0.9,intX,intY
If intX > 0 And intY > 0 Then 
    MoveTo intX, intY
    Delay 100
    LeftClick 1
    Delay 1000
End If

//找到图为止
i=0
While i = 0
    FindPic 0,0,1024,768,"Attachment:\图片名.bmp",0.9,intX,intY
    If intX > 0 And intY > 0 Then 
        i=1
        MoveTo intX, intY
        Delay 100
        LeftClick 1
        Delay 1000
    End If 
Wend

//查找有多个相同的图,直到图找不到为止
Do 
    FindPic 0,0,1024,768,"Attachment:\图片名.bmp",0.9,intX,intY
    If intX > 0 And intY > 0 Then 
        i=1
        MoveTo intX, intY
        Delay 100
        LeftClick 1
        Delay 1000
    Else 
        i = 0
    End If    
Loop  While i = 1

//查找有多个相同的图且每个图只找两遍
Do 
    FindPic 0,Y0,1024,768,"Attachment:\图片名.bmp",0.9,intX,intY
    If intX > 0 And intY > 0 Then 
        i=1
        MoveTo intX, intY
        Delay 100
        LeftClick 1
        Delay 1000
        If dx=intX
            Y0 = intY + 5
        End If
        dx = intX 
    Else 
        i = 0
    End If
Loop  While i = 1



 

你可能感兴趣的:(ajjl)