按键精灵的窗口插件
一、获取窗口句柄
1、查找指定窗口句柄命令(Find)
Hwnd=plugin.window.Find(0,"无标题 - 记事本") TracePrint Hwnd
2、查找子窗口句柄命令(FindEx)
Hwnd = plugin.window.Find(0,"无标题 - 记事本") TracePrint "主窗口句柄Hwnd="&Hwnd HwndEx1 = plugin.window.FindEx(Hwnd,0,"Edit",0) TracePrint "查找到的子窗口句柄为:"&HwndEx1
3、遍历窗口句柄命令(Search)
HwndEx = plugin.window.Search("无标题 - 记事本") TracePrint HwndEx MyArray = Split(HwndEx,"|") If Ubound(MyArray) >= 0 Then For i = 0 To Ubound(MyArray)-1 TracePrint "第"&(i+1)&"个窗口句柄为:"&MyArray(i) Next End If
4、遍历窗口句柄增强命令(Search)
HwndEx = plugin.window.SearchEx(0,"无标题 - 记事本",0) TracePrint HwndEx MyArray = Split(HwndEx,"|") If Ubound(MyArray) >= 0 Then For i = 0 To Ubound(MyArray)-1 TracePrint "第"&(i+1)&"个窗口句柄为:"&MyArray(i) Next End If
5、得到当前窗口的句柄命令(Foreground)
hwnd = Plugin.window.foreground() TracePrint hwnd
6、得到鼠标指向窗口的句柄命令(MousePoint)
hwnd = Plugin.window.mousepoint() TracePrint hwnd
7、得到可以发送按键消息的窗口句柄命令(GetKeyFocusWnd)
hwnd=plugin.window.getkeyfocuswnd() TracePrint hwnd
二、窗口移动后仍然可以补血的脚本
打开按键精灵脚本实验室网游自动加血网页:http://zy.anjian.com/lab/content_02.html。
可移动窗口自动加血脚本如下:
Hwnd = Plugin.window.MousePoint() TracePrint Hwnd While true srect = Plugin.window.GetClientRect(hwnd) TracePrint srect MyArray=split(srect,"|") x=MyArray(0) y=MyArray(1) l=MyArray(2) h=MyArray(3) TracePrint x&","&y&","&l&","&h Hpx = x+238 //血条80%血量位置 Hpy = y+45 TracePrint GetPixelColor(Hpx,Hpy) //获取血条80%血量位置颜色 IfColor Hpx, Hpy, "D8D8D8", 0 Then //如果血量低于80%,就按Q键加血 KeyPress "Q",1 End If Delay 200 Wend
- 上一篇: 按键精灵的找图找色命令
- 下一篇: 按键精灵的后台插件(Bkgnd)