<魔域>按键精灵脚本
用了三天时间才写完,实现了通过图片识别读取坐标数值,自动寻路等简单功能。
主要的难点在于游戏中的坐标系,和电脑屏幕的坐标系存在三维旋转关系,难以换算。
//全局变量:第一个数左上右下坐标
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 ...
随机推荐
- Android开发——导入github安卓项目源码
之前在Github上看见其他人的安卓项目源码,便是想下载源码来学习学习,但是下载之后一直导入失败,经过了漫长的摸索终于是成功了,便是分享一下经验 首先进入Github官网,找到想要学习的安卓源码 右上 ...
- <大话设计模式>笔记
读完了<大话设计模式>这本书,收获很多,对程序设计有了很多新的理解.将每章模式的大概要点做了些笔记以备查阅,一些设计模式书读完也对其了解得不是很透彻,需要以后在实践中来不断地加深理解吧.读 ...
- OC学习6——面相对象的三大特性
我们在学习Java的时候都知道,类有三大特性:继承,封装,多态,这也是面向对象的三大特征.OC学习篇之---类的三大特性(封装,继承,多态) 1.封装(Encapsulation)是指将对象的状态信息 ...
- Android 环境搭建、基础窗口window/Mac
1.五步搞定Android开发环境部署--非常详细的Android开发环境搭建教程 2.Android开发学习之路--MAC下Android Studio开发环境搭建 4.Android常用开发工具以 ...
- CJOJ 免费航班
Description 小Z在MOI比赛中获得了大奖,奖品是一张特殊的机 票.使用这张机票,可以在任意一个国家内的任意城市之间的免费飞行,只有跨国飞行时才会有额外的费用.小Z获得了一张地图,地图上有城 ...
- .NET使用DAO.NET实体类模型操作数据库
一.新建项目 打开vs2017,新建一个项目,命名为orm1 二.新建数据库 打开 SqlServer数据库,新建数据库 orm1,并新建表 student . 三.新建 ADO.NET 实体数据模型 ...
- CSS3 文字与字体相关样式
给文字添加阴影 文字换行 客户端文字 font-size-adjust属性 给文字添加阴影-text-shadow属性 text-shadow:length length length color 前 ...
- c#访问oracle数据库
想在c#中访问oracle数据库,毕竟是开发,想要轻量级访问oracle,客户机上无需安装oracle环境就能正常运行程序. 在网上找了相关资料,只需要引用一个dll即可实现. 访问代码(需引用dll ...
- mybatis源码分析(一)
mybatis源码分析(sqlSessionFactory生成过程) 1. mybatis框架在现在各个IT公司的使用不用多说,这几天看了mybatis的一些源码,赶紧做个笔记. 2. 看源码从一个d ...
- 解决 mysql 中文乱码
mysql版本:5.6.38 虽然创建实例时选择的是utf-8的utf8_general_ci,但是用其他程序保存中文时依旧出现乱码的情况. 记录一种可行的解决方案,即修改数据库的字符集. 由于该环境 ...