<魔域>按键精灵脚本
用了三天时间才写完,实现了通过图片识别读取坐标数值,自动寻路等简单功能。
主要的难点在于游戏中的坐标系,和电脑屏幕的坐标系存在三维旋转关系,难以换算。
- //全局变量:第一个数左上右下坐标
- 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 ...
随机推荐
- IDEA Translation插件中有道智云(有道翻译)应用ID,密钥申请教程
登录链接 该登录登录,该注册注册(信息随意填写) 自然语言翻译=>翻译实例=>创建实例(信息随意填写) QQ截图20170701231552.png 应用管理=>我的应用=>创 ...
- ES6之Set方法与Map方法
ES6提供了新的数据结构--Set与Map,Set本身是一个构造函数且成员的值是唯一的,没有重复的值!!!Set()是一个存储已排序的无重复元素的数据而Map()是一对数据Map()使用关键值Key来 ...
- Python学习日记:day7-----集合
1.基础数据类型汇总补充 1,list: 在循环一个列表是,最好不能删除列表中的元素. 2,bool 空列表.int:0.空str.空dict.空set--->bool:false 其余为tru ...
- Java用代码获取classes目录下的文件的方式
假设我们有个Maven的Web项目,其中有src/main/java和src/main/resources两个输出目录(注意这两个目录下的内容运行后都会输出到classes目录下), 而在src/ma ...
- 利用jquery实现电商网站常用特效之:五星评分
这篇文章主要为大家详细介绍了基于jquery实现五星好评,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 在电商网站,我们经常会用到五星评分的功能,现在用jQuery实现一个简单的demo: 1.引 ...
- 读Zepto源码之assets模块
assets 模块是为解决 Safari 移动版加载图片过大过多时崩溃的问题.因为没有处理过这样的场景,所以这部分的代码解释不会太多,为了说明这个问题,我翻译了<How to work arou ...
- PXE+Kickstart 全自动安装部署CentOS7.4
一.简介 1.什么是PXE PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过 ...
- Python 项目实践三(Web应用程序)第四篇
接着上节继续学习,本章将建立用户账户 Web应用程序的核心是让任何用户都能够注册账户并能够使用它,不管用户身处何方.在本章中,你将创建一些表单,让用户能够添加主题和条目,以及编辑既有的条目.你还将学习 ...
- Life In Changsha College- 第二次冲刺
第二次冲刺任务 设计留言板功能. 用户故事 用户打开"生活在长大"的界面 程序首页展示校园服务,论坛等相关信息 用户选择留言板 程序界面跳转 用户查看留言,并可以输入留言内容 提交 ...
- 微信跳一跳辅助自动跳Python
一.说明 此代码借鉴github一位大神所写,已经做了简化合并处理,如果能成功连上手机并运行,可以实现程序自动玩游戏,刷个1000+的分数轻轻松松 github源码地址 https://github. ...