用了三天时间才写完,实现了通过图片识别读取坐标数值,自动寻路等简单功能。

主要的难点在于游戏中的坐标系,和电脑屏幕的坐标系存在三维旋转关系,难以换算。

 //全局变量:第一个数左上右下坐标
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

<魔域>按键精灵脚本的更多相关文章

  1. 按键精灵 句柄 获得句柄 控制windows窗口 后台

    新建一个文本文档,打开,Windows就会给这个文本文档的窗口临时分配唯一的一串数字来标识这个窗体,以区别于其他窗口,这串数字就叫句柄.   因为句柄是临时随机分配的,所以每次虽然是打开同一个文件,但 ...

  2. 按键精灵saystring无法使用的几种解决方案

    1.当输入密码无法使用“SayString”.“Ctrl+V”时,改用“KeyPress”的方法 戏谷游戏的登录画面,“密码输入” 是会挡按键精灵的“SayString”这指令,还有“Ctrl+V”贴 ...

  3. 按键精灵对APP自动化测试(上)

    简单介绍下应用背景:测试安卓app时发现重复点击某一按钮的时候会出现报错,开发修复后提交测试.如果采用手动点击按钮,效率不高,在领导提示下使用按键精灵实现自动操作. 一.       安卓手机按键精灵 ...

  4. 按键精灵如何批量复制文本,再往excel里面一次性粘贴?

    原帖地址 http://zhidao.baidu.com/link?url=M2A9E1JF7wAzjtxMQG9uiW_PvP39HVlfwn6zDMzk9m6U05JA37SrgDcrVXg_c9 ...

  5. 按键精灵如何调用Excel及按键精灵写入Excel数据的方法教程---入门自动操作表格

    首先来建立一个新的Excel文档,在桌面上点击右键,选择[新建]-[Excel工作表],命名为[新手学员]. 现在这个新Excel文档是空白的,我们接下来会通过按键精灵的脚本来打开并写入一些数据.打开 ...

  6. 按键精灵对VBS的支持

    VBSBegin…VBSEnd(VBS块)格式:VBSBegin...VBSEnd用途:可以在VBS块的区域内随意的书写VBS语法指令. 更多说明:由于彻底的转向VBS语言,会导致goto语句不能被兼 ...

  7. 自己开发iOS版按键精灵--TTouch

    利用闲余时间,把之前的按键录制和播放整理了一些,开发了一个iOS版按键录制.播放的越狱APP,类似按键精灵.触动精灵等按键类的基本功能.脚本采用lua语法格式,可直接执行lua脚本,通过lua和obj ...

  8. C#实现按键精灵的'找图' '找色' '找字'的功能

    http://www.cnblogs.com/JimmyBright/p/4355862.html 背景:游戏辅助功能通常使用按键精灵编写脚本,按键精灵的最大卖点就是能够找到画面中字,图,色,这对于模 ...

  9. 按键精灵安卓版 tap、touch命令 不好用的解决办法!

    用按键精灵手机版写脚本来操作新浪微博APP,在关注列表页自动取消关注,代码如下: If x > -1 And y > -1 Then delay 1000 tap x,y delay 10 ...

随机推荐

  1. LeetCode #1 TwoSum

    Description Given an array of integers, return indices of the two numbers such that they add up to a ...

  2. iOS知识点、面试题 之二

    最近面试,与大家分享一下,分三文给大家: 当然Xcode新版本区别,以及iOS新特性 Xcode8 和iOS 10 在之前文章有发过,感兴趣的可以查阅: http://www.cnblogs.com/ ...

  3. 通过 JS 实现简单的拖拽功能并且可以在特定元素上禁止拖拽

    前言 关于讲解 JS 的拖拽功能的文章数不胜数,我确实没有必要大费周章再写一篇重复的文章来吸引眼球.本文的重点是讲解如何在某些特定的元素上禁止拖拽.这是我在编写插件时遇到的问题,其实很多插件的拖拽功能 ...

  4. MySQL sql语句获取当前日期|时间|时间戳

    1.1 获得当前日期+时间(date + time)函数:now() mysql> select now();+———————+| now() |+———————+| 2013-04-08 20 ...

  5. js浏览器对象navigator

    移动端通常需要判断当前设备的类型,比如安卓,ios等.输出浏览器的请求代理,可以判断浏览器类型.js代码如下 判断当前浏览器的请求代理 我是出来玩的! <!DOCTYPE html> &l ...

  6. android的ADK下载地址

    把下面所有的包下载到temp目录下进行安装. 用代理http://ppdaili.com/https://dl-ssl.google.com/android/repository/repository ...

  7. php使用websocket示例详解

    一.php 中处理 websocket WebSocket 连接是由客户端主动发起的,所以一切要从客户端出发.第一步是要解析拿到客户端发过来的 Sec-WebSocket-Key 字符串. 复制代码代 ...

  8. crontabs linux定时任务功能安装

    crontab命令常见于Unix和Linux的操作系统之中,用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于"crontab"文件中,以供之后读取和执行.通常 ...

  9. (python)leetcode刷题笔记03 Longest Substring Without Repeating Characters

    3. Longest Substring Without Repeating Characters Given a string, find the length of the longest sub ...

  10. JAVA类的创建: 创建JAVA的类 ,JAVA的字段,JAVA类的方法

    1. 创建Java的类 如果说Java的一切都是对象,那么类型就是决定了某一类对象的外观与行为.可是类型的关键字不是type,而是class,创建一个新的类型要用下面的代码: 1 2 3 class ...