<魔域>按键精灵脚本
用了三天时间才写完,实现了通过图片识别读取坐标数值,自动寻路等简单功能。
主要的难点在于游戏中的坐标系,和电脑屏幕的坐标系存在三维旋转关系,难以换算。
//全局变量:第一个数左上右下坐标
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 ...
随机推荐
- 【CSS3】边框
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Mac和Xcode常用的快捷键
Mac电脑一般都不怎么用鼠标,因此除了触摸屏的各种双指.三指甚至四指的操作之外,快捷键的使用可以带来非常大的便利,本文则主要收集整理了自己在Mac常规和Xcode开发过程中常用的一些快捷键. 一.Ma ...
- 并行cmd
#!/bin/bash ]; then echo -e "usage : \n\t$0 hostList REMOTE_CMD" echo -e "example: \n ...
- 669. Trim a Binary Search Tree
Given a binary search tree and the lowest and highest boundaries as `L`and `R`, trim the tree so t ...
- ArcGIS API for JavaScript 4.2学习笔记[7] 鹰眼(缩略图的实现及异步处理、Promise、回调函数、监听的笔记)
文前说明:关于style就是页面的css暂时不做评论,因为官方给的例子的样式实在太简单了,照抄阅读即可. 这篇文章有着大量AJS 4.x版本添加的内容,如监听watch.Promise对象.回调函数. ...
- python 动态加载类对象
第一步 加载模块 module =__import__("modulename",fromlist=['']) 第二部 加载类对象 cls = getattr(module, & ...
- 封装数据库配置文件App配置文件
<connectionStrings> <add name="strCon" connectionString="Data Source=.;Ini ...
- CPP--正码,反码,补码~附整数溢出的探讨
之前说到了long的争议(http://www.cnblogs.com/dotnetcrazy/p/8059210.html),这边就不用long来举例了,用int吧 可以看一下这篇文章(http:/ ...
- SSIS 实用表达式部分总结
下面,列出一些实用的表达式: 1,路径取文件名 RIGHT([FilePath],FINDSTRING(REVERSE([FilePath]),) - ) RIGHT(@[User::FilePath ...
- PHP按行读取文件 去掉换行符"\n"
第一种: $content=str_replace("\n","",$content); echo $content; 或者: $content=str_rep ...