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

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

  1. //全局变量:第一个数左上右下坐标
  2. Global first1x
  3. Global first1y
  4. Global first2x
  5. Global first2y
  6.  
  7. //全局变量:xp技点位置
  8. Global xpx
  9. Global xpy
  10.  
  11. //全局变量:读取到的数字
  12. Global x1
  13. Global x2
  14. Global x3
  15. Global x4
  16. Global y1
  17. Global y2
  18. Global y3
  19. Global y4
  20.  
  21. //全局变量:读到的坐标
  22. Global nowx
  23. Global nowy
  24.  
  25. //全局变量:屏幕中间点实际坐标
  26. Global actualx
  27. Global actualy
  28.  
  29. //主体
  30.  
  31. //初始化变量
  32. Call init()
  33.  
  34. //自动按键
  35. Call startKey()
  36.  
  37. //自动点击XP技
  38. If Form1.CheckBox1.Value = Then
  39. BeginThread findclick()
  40. End If
  41.  
  42. //自动寻路
  43. Select Case Form1.ComboBox1.ListIndex
  44. Case
  45. Call go1()
  46. Case Else
  47. End Select
  48.  
  49. // 子程序:按1寻路
  50. Sub go1()
  51. While
  52. Call headTo(, )
  53. Call headTo(, )
  54. Call headTo(, )
  55. Call headTo(, )
  56. Call headTo(, )
  57. Call headTo(, )
  58. Wend
  59. End Sub
  60.  
  61. //子程序:初始化
  62. Sub init()
  63.  
  64. first1x =
  65. first1y =
  66. first2x =
  67. first2y =
  68.  
  69. xpx =
  70. xpy =
  71.  
  72. //获取屏幕中间点实际坐标
  73. actualx = Plugin.GetSysInfo.GetScreenResolutionX /
  74. actualy = Plugin.GetSysInfo.GetScreenResolutionY /
  75.  
  76. End Sub
  77.  
  78. //子程序:得到当前坐标,保存到nowx,nowy
  79. Sub get()
  80.  
  81. //得出X坐标
  82. x1 = find(first1x, first1y, first2x, first2y)
  83.  
  84. x2 = find(first1x + , first1y, first2x + , first2y)
  85.  
  86. If x2 >= Then
  87. x3 = find(first1x + , first1y, first2x + , first2y)
  88. If x3 >= Then
  89. x4 = find(first1x + , first1y, first2x + , first2y)
  90. If x4 >= Then
  91. nowx = x1 * + x2 * + x3 * + x4
  92. Else
  93. nowx = x1* + x2* + x3
  94. End If
  95. Else
  96. nowx = x1* + x2
  97. End If
  98. Else
  99. nowx = x1
  100. End If
  101.  
  102. //得出Y坐标
  103. y1 = find(first1x + , first1y, first2x + , first2y)
  104.  
  105. y2 = find(first1x + , first1y, first2x + , first2y)
  106.  
  107. If y2 >= Then
  108. y3 = find(first1x + , first1y, first2x + , first2y)
  109. If y3 >= Then
  110. y4 = find(first1x + , first1y, first2x + , first2y)
  111. If y4 >= Then
  112. nowy = y1 * + y2 * + y3 * + y4
  113. Else
  114. nowy = y1* + y2* + y3
  115. End If
  116. Else
  117. nowy = y1* + y2
  118. End If
  119. Else
  120. nowy = y1
  121. End If
  122.  
  123. End Sub
  124.  
  125. //函数:通过参数first1x,first1y,first2x,first2y返回检测到的数字
  126. Function find(first1x, first1y, first2x, first2y)
  127.  
  128. FindPic first1x,first1y,first2x,first2y,"Attachment:\0.bmp",,intX,intY
  129. If intX > And intY > Then
  130. find =
  131. Exit Function
  132. End If
  133. FindPic first1x,first1y,first2x,first2y,"Attachment:\1.bmp",,intX,intY
  134. If intX > And intY > Then
  135. find =
  136. Exit Function
  137. End If
  138. FindPic first1x,first1y,first2x,first2y,"Attachment:\2.bmp",,intX,intY
  139. If intX > And intY > Then
  140. find =
  141. Exit Function
  142. End If
  143. FindPic first1x,first1y,first2x,first2y,"Attachment:\3.bmp",,intX,intY
  144. If intX > And intY > Then
  145. find =
  146. Exit Function
  147. End If
  148. FindPic first1x,first1y,first2x,first2y,"Attachment:\4.bmp",,intX,intY
  149. If intX > And intY > Then
  150. find =
  151. Exit Function
  152. End If
  153. FindPic first1x,first1y,first2x,first2y,"Attachment:\5.bmp",,intX,intY
  154. If intX > And intY > Then
  155. find =
  156. Exit Function
  157. End If
  158. FindPic first1x,first1y,first2x,first2y,"Attachment:\6.bmp",,intX,intY
  159. If intX > And intY > Then
  160. find =
  161. Exit Function
  162. End If
  163. FindPic first1x,first1y,first2x,first2y,"Attachment:\7.bmp",,intX,intY
  164. If intX > And intY > Then
  165. find =
  166. Exit Function
  167. End If
  168. FindPic first1x,first1y,first2x,first2y,"Attachment:\8.bmp",,intX,intY
  169. If intX > And intY > Then
  170. find =
  171. Exit Function
  172. End If
  173. FindPic first1x,first1y,first2x,first2y,"Attachment:\9.bmp",,intX,intY
  174. If intX > And intY > Then
  175. find =
  176. Exit Function
  177. End If
  178.  
  179. find = -
  180.  
  181. End Function
  182.  
  183. //子程序:前往目标地点
  184. Sub headTo(x, y)
  185. BeginThread click
  186. While
  187. Call get()
  188. a = nowx - x
  189. b = nowy - y
  190.  
  191. // 判断是否已经到达
  192. If (a * a + b * b) < Then
  193. Exit Sub
  194. End If
  195.  
  196. // 屏幕向量
  197. screenx = (b - a) * 1.1
  198. screeny = (a + b) * 0.6
  199.  
  200. d = / (Sqr( + (screenx * screenx) / (screeny * screeny)))
  201. c = (screenx / screeny) * d
  202.  
  203. If c * screenx < Then
  204. c = -c
  205. End If
  206.  
  207. If d * screeny > Then
  208. d = -d
  209. End If
  210.  
  211. c = c + actualx
  212. d = d + actualy
  213.  
  214. // 鼠标指向
  215. MoveTo c, d
  216. Delay
  217. Wend
  218.  
  219. End Sub
  220.  
  221. // 线程:不停点击鼠标
  222. Sub click()
  223. clickID = GetThreadID()
  224. While
  225. LeftClick
  226. Delay
  227. Wend
  228. End Sub
  229.  
  230. // 子程序:开始所有键盘点击
  231. Sub startkey()
  232. Select Case Form1.KeyBox1.ListIndex
  233. Case
  234. ms = Form1.MsBox1.Caption
  235. BeginThread presskey(, ms)
  236. Case
  237. ms = Form1.MsBox1.Caption
  238. BeginThread presskey(, ms)
  239. Case
  240. ms = Form1.MsBox1.Caption
  241. BeginThread presskey(, ms)
  242. Case
  243. ms = Form1.MsBox1.Caption
  244. BeginThread presskey(, ms)
  245. Case
  246. ms = Form1.MsBox1.Caption
  247. BeginThread presskey(, ms)
  248. Case
  249. ms = Form1.MsBox1.Caption
  250. BeginThread presskey(, ms)
  251. Case
  252. ms = Form1.MsBox1.Caption
  253. BeginThread presskey(, ms)
  254. Case
  255. ms = Form1.MsBox1.Caption
  256. BeginThread presskey(, ms)
  257. Case
  258. ms = Form1.MsBox1.Caption
  259. BeginThread presskey(, ms)
  260. Case
  261. ms = Form1.MsBox1.Caption
  262. BeginThread presskey(, ms)
  263. Case
  264. ms = Form1.MsBox1.Caption
  265. BeginThread presskey(, ms)
  266. Case
  267. ms = Form1.MsBox1.Caption
  268. BeginThread presskey(, ms)
  269. Case
  270. ms = Form1.MsBox1.Caption
  271. BeginThread presskey(, ms)
  272. Case
  273. ms = Form1.MsBox1.Caption
  274. BeginThread presskey(, ms)
  275. Case
  276. ms = Form1.MsBox1.Caption
  277. BeginThread presskey(, ms)
  278. Case
  279. ms = Form1.MsBox1.Caption
  280. BeginThread presskey(, ms)
  281. Case
  282. ms = Form1.MsBox1.Caption
  283. BeginThread presskey(, ms)
  284. Case
  285. ms = Form1.MsBox1.Caption
  286. BeginThread presskey(, ms)
  287. Case Else
  288. End Select
  289.  
  290. Select Case Form1.KeyBox2.ListIndex
  291. Case
  292. ms = Form1.MsBox2.Caption
  293. BeginThread presskey(, ms)
  294. Case
  295. ms = Form1.MsBox2.Caption
  296. BeginThread presskey(, ms)
  297. Case
  298. ms = Form1.MsBox2.Caption
  299. BeginThread presskey(, ms)
  300. Case
  301. ms = Form1.MsBox2.Caption
  302. BeginThread presskey(, ms)
  303. Case
  304. ms = Form1.MsBox2.Caption
  305. BeginThread presskey(, ms)
  306. Case
  307. ms = Form1.MsBox2.Caption
  308. BeginThread presskey(, ms)
  309. Case
  310. ms = Form1.MsBox2.Caption
  311. BeginThread presskey(, ms)
  312. Case
  313. ms = Form1.MsBox2.Caption
  314. BeginThread presskey(, ms)
  315. Case
  316. ms = Form1.MsBox2.Caption
  317. BeginThread presskey(, ms)
  318. Case
  319. ms = Form1.MsBox2.Caption
  320. BeginThread presskey(, ms)
  321. Case
  322. ms = Form1.MsBox2.Caption
  323. BeginThread presskey(, ms)
  324. Case
  325. ms = Form1.MsBox2.Caption
  326. BeginThread presskey(, ms)
  327. Case
  328. ms = Form1.MsBox2.Caption
  329. BeginThread presskey(, ms)
  330. Case
  331. ms = Form1.MsBox2.Caption
  332. BeginThread presskey(, ms)
  333. Case
  334. ms = Form1.MsBox2.Caption
  335. BeginThread presskey(, ms)
  336. Case
  337. ms = Form1.MsBox2.Caption
  338. BeginThread presskey(, ms)
  339. Case
  340. ms = Form1.MsBox2.Caption
  341. BeginThread presskey(, ms)
  342. Case
  343. ms = Form1.MsBox2.Caption
  344. BeginThread presskey(, ms)
  345. Case Else
  346. End Select
  347.  
  348. Select Case Form1.KeyBox3.ListIndex
  349. Case
  350. ms = Form1.MsBox3.Caption
  351. BeginThread presskey(, ms)
  352. Case
  353. ms = Form1.MsBox3.Caption
  354. BeginThread presskey(, ms)
  355. Case
  356. ms = Form1.MsBox3.Caption
  357. BeginThread presskey(, ms)
  358. Case
  359. ms = Form1.MsBox3.Caption
  360. BeginThread presskey(, ms)
  361. Case
  362. ms = Form1.MsBox3.Caption
  363. BeginThread presskey(, ms)
  364. Case
  365. ms = Form1.MsBox3.Caption
  366. BeginThread presskey(, ms)
  367. Case
  368. ms = Form1.MsBox3.Caption
  369. BeginThread presskey(, ms)
  370. Case
  371. ms = Form1.MsBox3.Caption
  372. BeginThread presskey(, ms)
  373. Case
  374. ms = Form1.MsBox3.Caption
  375. BeginThread presskey(, ms)
  376. Case
  377. ms = Form1.MsBox3.Caption
  378. BeginThread presskey(, ms)
  379. Case
  380. ms = Form1.MsBox3.Caption
  381. BeginThread presskey(, ms)
  382. Case
  383. ms = Form1.MsBox3.Caption
  384. BeginThread presskey(, ms)
  385. Case
  386. ms = Form1.MsBox3.Caption
  387. BeginThread presskey(, ms)
  388. Case
  389. ms = Form1.MsBox3.Caption
  390. BeginThread presskey(, ms)
  391. Case
  392. ms = Form1.MsBox3.Caption
  393. BeginThread presskey(, ms)
  394. Case
  395. ms = Form1.MsBox3.Caption
  396. BeginThread presskey(, ms)
  397. Case
  398. ms = Form1.MsBox3.Caption
  399. BeginThread presskey(, ms)
  400. Case
  401. ms = Form1.MsBox3.Caption
  402. BeginThread presskey(, ms)
  403. Case Else
  404. End Select
  405.  
  406. Select Case Form1.KeyBox4.ListIndex
  407. Case
  408. ms = Form1.MsBox4.Caption
  409. BeginThread presskey(, ms)
  410. Case
  411. ms = Form1.MsBox4.Caption
  412. BeginThread presskey(, ms)
  413. Case
  414. ms = Form1.MsBox4.Caption
  415. BeginThread presskey(, ms)
  416. Case
  417. ms = Form1.MsBox4.Caption
  418. BeginThread presskey(, ms)
  419. Case
  420. ms = Form1.MsBox4.Caption
  421. BeginThread presskey(, ms)
  422. Case
  423. ms = Form1.MsBox4.Caption
  424. BeginThread presskey(, ms)
  425. Case
  426. ms = Form1.MsBox4.Caption
  427. BeginThread presskey(, ms)
  428. Case
  429. ms = Form1.MsBox4.Caption
  430. BeginThread presskey(, ms)
  431. Case
  432. ms = Form1.MsBox4.Caption
  433. BeginThread presskey(, ms)
  434. Case
  435. ms = Form1.MsBox4.Caption
  436. BeginThread presskey(, ms)
  437. Case
  438. ms = Form1.MsBox4.Caption
  439. BeginThread presskey(, ms)
  440. Case
  441. ms = Form1.MsBox4.Caption
  442. BeginThread presskey(, ms)
  443. Case
  444. ms = Form1.MsBox4.Caption
  445. BeginThread presskey(, ms)
  446. Case
  447. ms = Form1.MsBox4.Caption
  448. BeginThread presskey(, ms)
  449. Case
  450. ms = Form1.MsBox4.Caption
  451. BeginThread presskey(, ms)
  452. Case
  453. ms = Form1.MsBox4.Caption
  454. BeginThread presskey(, ms)
  455. Case
  456. ms = Form1.MsBox4.Caption
  457. BeginThread presskey(, ms)
  458. Case
  459. ms = Form1.MsBox4.Caption
  460. BeginThread presskey(, ms)
  461. Case Else
  462. End Select
  463. End Sub
  464.  
  465. //线程:每隔ms按num键
  466. Sub presskey(num,mss)
  467. While
  468. KeyPress num,
  469. Delay ms
  470. Wend
  471. End Sub
  472.  
  473. // 查找和点击XP技能
  474. Sub findclick()
  475. While
  476. IfColor xpx, xpy, "CF71A9", Then
  477. SaveMousePos
  478. MoveTo ,
  479. LeftClick
  480. RestoreMousePos
  481. Else
  482. End If
  483. Delay
  484. Wend
  485. 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. IDEA Translation插件中有道智云(有道翻译)应用ID,密钥申请教程

    登录链接 该登录登录,该注册注册(信息随意填写) 自然语言翻译=>翻译实例=>创建实例(信息随意填写) QQ截图20170701231552.png 应用管理=>我的应用=>创 ...

  2. ES6之Set方法与Map方法

    ES6提供了新的数据结构--Set与Map,Set本身是一个构造函数且成员的值是唯一的,没有重复的值!!!Set()是一个存储已排序的无重复元素的数据而Map()是一对数据Map()使用关键值Key来 ...

  3. Python学习日记:day7-----集合

    1.基础数据类型汇总补充 1,list: 在循环一个列表是,最好不能删除列表中的元素. 2,bool 空列表.int:0.空str.空dict.空set--->bool:false 其余为tru ...

  4. Java用代码获取classes目录下的文件的方式

    假设我们有个Maven的Web项目,其中有src/main/java和src/main/resources两个输出目录(注意这两个目录下的内容运行后都会输出到classes目录下), 而在src/ma ...

  5. 利用jquery实现电商网站常用特效之:五星评分

    这篇文章主要为大家详细介绍了基于jquery实现五星好评,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 在电商网站,我们经常会用到五星评分的功能,现在用jQuery实现一个简单的demo: 1.引 ...

  6. 读Zepto源码之assets模块

    assets 模块是为解决 Safari 移动版加载图片过大过多时崩溃的问题.因为没有处理过这样的场景,所以这部分的代码解释不会太多,为了说明这个问题,我翻译了<How to work arou ...

  7. PXE+Kickstart 全自动安装部署CentOS7.4

    一.简介 1.什么是PXE PXE(preboot execute environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过 ...

  8. Python 项目实践三(Web应用程序)第四篇

    接着上节继续学习,本章将建立用户账户 Web应用程序的核心是让任何用户都能够注册账户并能够使用它,不管用户身处何方.在本章中,你将创建一些表单,让用户能够添加主题和条目,以及编辑既有的条目.你还将学习 ...

  9. Life In Changsha College- 第二次冲刺

    第二次冲刺任务 设计留言板功能. 用户故事 用户打开"生活在长大"的界面 程序首页展示校园服务,论坛等相关信息 用户选择留言板 程序界面跳转 用户查看留言,并可以输入留言内容 提交 ...

  10. 微信跳一跳辅助自动跳Python

    一.说明 此代码借鉴github一位大神所写,已经做了简化合并处理,如果能成功连上手机并运行,可以实现程序自动玩游戏,刷个1000+的分数轻轻松松 github源码地址 https://github. ...