<魔域>按键精灵脚本

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

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

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

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

阴阳师按键精灵脚本

用电脑,解放你的双手! 有任何意见.需求或者bug,请在下方评论留言. 声明 此脚本仅限于交流学习,请勿过分使用. 环境设置 本脚本必须配合夜神模拟器使用 夜神模拟器必须设置为800*600分辨率 脚本文件夹必须放在D盘,且名字不能更改 即目录结构为: +-- D `-- 按键 +-- img `-- 阴阳师.exe 具体点击下载,解压并移动到D盘.再右键发送一个快捷方式到桌面即可 使用方法 打开模拟器,打开游戏 在脚本中选择功能,点击开始 ToDo: 改变文件目录,使可以移动到其他位置. 结界

按键精灵脚本

1电脑版读取文件脚本 Dim path  path = "C:/Users/Administrator/Desktop/accounts" //直接读取文件到变量,文件的每一行在变量中以|分隔 Text = Plugin.File.ReadFileEx(path) MessageBox "Text" & text  TracePrint Text   //只是调试状态才显示            //打开文件,循环读取每一行   Dim fileHandle

仙境传说-按键精灵脚步研究

仙境传说是很早以前非常流行的一款网络游戏,其中的人物设置的非常可爱,尤其是一些夸张的头饰和百变的插卡系统让人回味无穷.虽然从游戏性来说仍然逃不出韩国游戏泡菜的怪圈(或者说是一款标准的泡菜游戏),但仍然是可圈可点的. 游戏中玩家要耗费大量时间进行练级,虽然现在的代理昆仑也有经验奖励的措施,比如高级经验书,高级JOB经验书,双倍经验时间区等,但是要让玩家,特别是高等级的玩家进行练级仍然是一件非常痛苦的事情.常有的事是,三转100~110的职业往往要在熔岩地图上打一个熔岩波利的怪物来进行性价比较高的练

一个按键精灵后台发送消息的脚本

以前,我也用过按键精灵写过一些脚本,那时候经常用这个来挂机FB什么的. 那天,某网友问起,于是就回答了下 无非就是,抓句柄,然后相对定位坐标或者发送消息到固定窗体 代码如下: 1 //////////////////////////抓窗口句柄////////////////////////////////////////// 2 3 Dim Hwnd 4 5 Hwnd = Plugin.Window.MousePoint() 6 7 sWindow = Plugin.Window.IsWindo

最近听说搞脚本挺爽的 弄了个按键精灵的找图找色

首先你需要下载个按键精灵的软件.如下http://www.anjian.com/ 下好后就打开按键精灵,首先新建一个空白脚本,然后找到抓取按钮. 随便找张图来找色 比如如上这张,用抓取按钮选择右键找到色素点,如#c10b2a 然后将该值放到颜色/图形命令去 在图形找色这里,还有找图功能,其实原理都差不多,都是通过周边像素点的色值来找到符合这个值得点,这样就能找到所选的数据. 当你找到你想得到的句柄(windows的某些你想要获取的窗口)时,就可以通过找色或找图去设置你自己所要的功能.

用按键精灵写的手机端按键精灵批量加群的脚本

前几天朋友想在手机上面多加几个群,可是一个个的手工操作太难受了,于是就用按键精灵帮他写了一个自动加群的代码.分享给大家. KeepScreen True Delay 2000 Dim scrWidth, scrHeight,a,x,y,i,intX,intY scrWidth = GetScreenX() scrHeight = GetScreenY() 'ShowMessage scrWidth&"--"&scrHeight TracePrint scrWidth T

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

首先来建立一个新的Excel文档,在桌面上点击右键,选择[新建]-[Excel工作表],命名为[新手学员]. 现在这个新Excel文档是空白的,我们接下来会通过按键精灵的脚本来打开并写入一些数据.打开按键精灵软件,点击[新建],进入我的脚本界面,再点击进入[全部命令].在[全部命令]中选择[插件命令]-[office办公文档插件]-[打开Excel文档].在命令的下面可以看到命令的详细设置,点击[路径].在弹出窗口中选择[新手学员]的Excel文档,点击打开.可以在命令参数中看到引用的文档,点击

C#实现按键精灵的&#39;找图&#39; &#39;找色&#39; &#39;找字&#39;的功能

背景:游戏辅助功能通常使用按键精灵编写脚本,按键精灵的最大卖点就是能够找到画面中字,图,色,这对于模拟用户鼠标操作至关重要,这能找到道具,找到血量,实现自动打怪,自动补血,自动买卖道具,博主闲来无聊,看到一款按键精灵实现的辅助,于是乎想用WPF也写一款辅助工具,实现其核心的找图找色等功能.博主测试,对于背景复杂多变的画面,找不变图的成功率达到100%,找带透明的图,比如文字,能达到90%以上.默认您已经知道一个颜色值由argb构成,每个值范围都是0~255.网上发现不少人询问过该问题,几乎没有比

按键精灵

按键精灵是一款模拟鼠标键盘动作的软件.通过制作脚本,可以让按键精灵代替双手,自动执行一系列鼠标键盘动作.按键精灵简单易用,不需要任何编程知识就可以作出功能强大的脚本.只要在电脑前用双手可以完成的动作,按键精灵都可以替代完成.