---------绑定窗口函数----------------
--输出值 Hwnd ,Hwnd_0
/绑定思路,取应用窗口界面中比较有特征的部们截图,pictname.bmp、
/以前台找图的方式点击,这样会激活成当前窗口,然后取当前活动窗口句柄,以此达到取hwnd数的目录,
/利用上节的函数,取出该窗口的相关数据
/因此此方法绑定窗口,前提是要先打开应用,并要求屏幕上能观察到特征图标,以利于点击激活窗口为当前窗口
/*,点击的偏移量(偏移X, 偏移Y) 可以自行调试设定
Function window_band(pictname, 偏移X, 偏移Y)
If Hwnd = "" Then
Dim sRect,sRect0,intX,intY,n
window_band = 0
窗口绑定_intX = 0
窗口绑定_intY = 0
n = 0
For 100
Delay 2000
Rem sig_A
FindPic 0, 0, Plugin.Sys.GetScRX - 1, Plugin.Sys.GetScRY - 1, pic_path & pictname, 0.8, 窗口绑定_intX, 窗口绑定_intY
If 窗口绑定_intX > 0 and 窗口绑定_intY>0 Then
LockMouse
SaveMousePos
MoveTo 窗口绑定_intX + cint(偏移X), 窗口绑定_intY + cint(偏移Y)
Delay 50
leftClick 3
RestoreMousePos
UnlockMouse
Hwnd = Plugin.Window.GetKeyFocusWnd()
Hwnd_0 = Plugin.Window.Foreground()
If hwnd = hwnd_0 Then
Goto sig_A
End If
sRect = Plugin.Window.GetClientRect(Hwnd)
sRect0=split(sRect,"|")
If Clng(sRect0(1)) >= 0 and Hwnd <> "" Then
call window_size(Hwnd,Hwnd_0)
window_band = 1
Exit For
End If
End If
Next
If window_band = 1 Then
Call Lib.窗口.弹出对话框("绑定成功!开始运行!", 3, "", 0)
Delay 1000
End If
Else
call window_size(Hwnd,Hwnd_0)
window_band = 1
End If
End Function
原文地址:https://blog.51cto.com/12815848/2441516
时间: 2024-10-10 07:43:44