<魔域>按键精灵脚本
用了三天时间才写完,实现了通过图片识别读取坐标数值,自动寻路等简单功能。
主要的难点在于游戏中的坐标系,和电脑屏幕的坐标系存在三维旋转关系,难以换算。
//全局变量:第一个数左上右下坐标
Global first1x
Global first1y
Global first2x
Global first2y //全局变量:xp技点位置
Global xpx
Global xpy //全局变量:读取到的数字
Global x1
Global x2
Global x3
Global x4
Global y1
Global y2
Global y3
Global y4 //全局变量:读到的坐标
Global nowx
Global nowy //全局变量:屏幕中间点实际坐标
Global actualx
Global actualy //主体 //初始化变量
Call init() //自动按键
Call startKey() //自动点击XP技
If Form1.CheckBox1.Value = Then
BeginThread findclick()
End If //自动寻路
Select Case Form1.ComboBox1.ListIndex
Case
Call go1()
Case Else
End Select // 子程序:按1寻路
Sub go1()
While
Call headTo(, )
Call headTo(, )
Call headTo(, )
Call headTo(, )
Call headTo(, )
Call headTo(, )
Wend
End Sub //子程序:初始化
Sub init() first1x =
first1y =
first2x =
first2y = xpx =
xpy = //获取屏幕中间点实际坐标
actualx = Plugin.GetSysInfo.GetScreenResolutionX /
actualy = Plugin.GetSysInfo.GetScreenResolutionY / End Sub //子程序:得到当前坐标,保存到nowx,nowy
Sub get() //得出X坐标
x1 = find(first1x, first1y, first2x, first2y) x2 = find(first1x + , first1y, first2x + , first2y) If x2 >= Then
x3 = find(first1x + , first1y, first2x + , first2y)
If x3 >= Then
x4 = find(first1x + , first1y, first2x + , first2y)
If x4 >= Then
nowx = x1 * + x2 * + x3 * + x4
Else
nowx = x1* + x2* + x3
End If
Else
nowx = x1* + x2
End If
Else
nowx = x1
End If //得出Y坐标
y1 = find(first1x + , first1y, first2x + , first2y) y2 = find(first1x + , first1y, first2x + , first2y) If y2 >= Then
y3 = find(first1x + , first1y, first2x + , first2y)
If y3 >= Then
y4 = find(first1x + , first1y, first2x + , first2y)
If y4 >= Then
nowy = y1 * + y2 * + y3 * + y4
Else
nowy = y1* + y2* + y3
End If
Else
nowy = y1* + y2
End If
Else
nowy = y1
End If End Sub //函数:通过参数first1x,first1y,first2x,first2y返回检测到的数字
Function find(first1x, first1y, first2x, first2y) FindPic first1x,first1y,first2x,first2y,"Attachment:\0.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\1.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\2.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\3.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\4.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\5.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\6.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\7.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\8.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If
FindPic first1x,first1y,first2x,first2y,"Attachment:\9.bmp",,intX,intY
If intX > And intY > Then
find =
Exit Function
End If find = - End Function //子程序:前往目标地点
Sub headTo(x, y)
BeginThread click
While
Call get()
a = nowx - x
b = nowy - y // 判断是否已经到达
If (a * a + b * b) < Then
Exit Sub
End If // 屏幕向量
screenx = (b - a) * 1.1
screeny = (a + b) * 0.6 d = / (Sqr( + (screenx * screenx) / (screeny * screeny)))
c = (screenx / screeny) * d If c * screenx < Then
c = -c
End If If d * screeny > Then
d = -d
End If c = c + actualx
d = d + actualy // 鼠标指向
MoveTo c, d
Delay
Wend End Sub // 线程:不停点击鼠标
Sub click()
clickID = GetThreadID()
While
LeftClick
Delay
Wend
End Sub // 子程序:开始所有键盘点击
Sub startkey()
Select Case Form1.KeyBox1.ListIndex
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox1.Caption
BeginThread presskey(, ms)
Case Else
End Select Select Case Form1.KeyBox2.ListIndex
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox2.Caption
BeginThread presskey(, ms)
Case Else
End Select Select Case Form1.KeyBox3.ListIndex
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox3.Caption
BeginThread presskey(, ms)
Case Else
End Select Select Case Form1.KeyBox4.ListIndex
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case
ms = Form1.MsBox4.Caption
BeginThread presskey(, ms)
Case Else
End Select
End Sub //线程:每隔ms按num键
Sub presskey(num,mss)
While
KeyPress num,
Delay ms
Wend
End Sub // 查找和点击XP技能
Sub findclick()
While
IfColor xpx, xpy, "CF71A9", Then
SaveMousePos
MoveTo ,
LeftClick
RestoreMousePos
Else
End If
Delay
Wend
End Sub
<魔域>按键精灵脚本的更多相关文章
- 按键精灵 句柄 获得句柄 控制windows窗口 后台
新建一个文本文档,打开,Windows就会给这个文本文档的窗口临时分配唯一的一串数字来标识这个窗体,以区别于其他窗口,这串数字就叫句柄. 因为句柄是临时随机分配的,所以每次虽然是打开同一个文件,但 ...
- 按键精灵saystring无法使用的几种解决方案
1.当输入密码无法使用“SayString”.“Ctrl+V”时,改用“KeyPress”的方法 戏谷游戏的登录画面,“密码输入” 是会挡按键精灵的“SayString”这指令,还有“Ctrl+V”贴 ...
- 按键精灵对APP自动化测试(上)
简单介绍下应用背景:测试安卓app时发现重复点击某一按钮的时候会出现报错,开发修复后提交测试.如果采用手动点击按钮,效率不高,在领导提示下使用按键精灵实现自动操作. 一. 安卓手机按键精灵 ...
- 按键精灵如何批量复制文本,再往excel里面一次性粘贴?
原帖地址 http://zhidao.baidu.com/link?url=M2A9E1JF7wAzjtxMQG9uiW_PvP39HVlfwn6zDMzk9m6U05JA37SrgDcrVXg_c9 ...
- 按键精灵如何调用Excel及按键精灵写入Excel数据的方法教程---入门自动操作表格
首先来建立一个新的Excel文档,在桌面上点击右键,选择[新建]-[Excel工作表],命名为[新手学员]. 现在这个新Excel文档是空白的,我们接下来会通过按键精灵的脚本来打开并写入一些数据.打开 ...
- 按键精灵对VBS的支持
VBSBegin…VBSEnd(VBS块)格式:VBSBegin...VBSEnd用途:可以在VBS块的区域内随意的书写VBS语法指令. 更多说明:由于彻底的转向VBS语言,会导致goto语句不能被兼 ...
- 自己开发iOS版按键精灵--TTouch
利用闲余时间,把之前的按键录制和播放整理了一些,开发了一个iOS版按键录制.播放的越狱APP,类似按键精灵.触动精灵等按键类的基本功能.脚本采用lua语法格式,可直接执行lua脚本,通过lua和obj ...
- C#实现按键精灵的'找图' '找色' '找字'的功能
http://www.cnblogs.com/JimmyBright/p/4355862.html 背景:游戏辅助功能通常使用按键精灵编写脚本,按键精灵的最大卖点就是能够找到画面中字,图,色,这对于模 ...
- 按键精灵安卓版 tap、touch命令 不好用的解决办法!
用按键精灵手机版写脚本来操作新浪微博APP,在关注列表页自动取消关注,代码如下: If x > -1 And y > -1 Then delay 1000 tap x,y delay 10 ...
随机推荐
- .NET 实现Base-64加密解密处理
.NET 实现Base-64加密解密处理 using System; using System.Collections.Generic; using System.Linq; using System ...
- java-生成任意格式的json数据
最近研究java的东西.之前靠着自己的摸索,实现了把java对象转成json格式的数据的功能,返回给前端.当时使用的是 JSONObject.fromObject(object) 方法把java对象换 ...
- jsDOM编程-乌龟抓小鸡游戏
<html> <head> <title>js乌龟抓小鸡游戏 </title> <meta http-equiv="conten ...
- oracle自动备份_expdp_Linux
[oracle@hbsjxtdb1 ~]$ crontab -e 0 4 * * * /backup/script/backupexpdp.sh [oracle@hbsjxtdb1 ~]$ cront ...
- PhoneGap开发环境搭建
项目中要用PhoneGap开发,了解了下基本规则,记录一下,以备后查.(只针对Android平台) 一.安装 在安装PhoneGap开发环境之前,需要先安装以下框架: 1.Java SDK 2.Ecl ...
- springBoot系列教程03:redis的集成及使用
1.为了高可用,先安装redis集群 参考我的另一篇文章 http://www.cnblogs.com/xiaochangwei/p/7993065.html 2.POM中引入redis <de ...
- 获取两个时间节点的月份列表&&每个月份的开始时间及结束时间
//Q:从今天起之前五个月的列表 date_default_timezone_set('PRC'); $time=strtotime('-5 month'); //包含本月 $begin = strt ...
- TCP/IP协议栈(三)——linux 向下的报文处理
应用程序连接服务器时,目的地套接字地址(端口号和IP地址)以参数形式传递给系统调用connect(tcp_v4_connect()).下面逐步介绍初始化该连接 检查内核路由表,查找给定目的地IP地址路 ...
- MySQL查询(进阶)(每个标点都是重点)
MySQL 是工作中很普遍的需要用到的,所以必须掌握,而 之前我们一直说的都是怎么存. 你只会存不会取有个屁用.所以希望大家在如何查询读取数据这方面多下点功夫. 这篇和上一篇都是干货,我也是第一次学. ...
- js模块化规范
1. CommonJS 用于服务端模块化编程,比如nodejs就采用此规范: 一个文件就是一个模块,require方法用来加载模块,该方法读取一个文件并执行,最后返回文件内部的module.expor ...