和之前战士差不多的功能,挂机地图是尸魔洞2层。玩了两天,腻了,游戏也删了。把脚本记录下来,好歹算是学习按键精灵的过程。
功能
自动打怪、捡物、买双倍卷轴、买药,自动修复装备。
脚本
//设置大漠路径以及字库名
Set dm = createobject("dm.dmsoft")
dm.SetPath ("d:")
dm_ret = dm.SetDict(0,"lanhuo.txt")
//绑定窗口和模式
hwnd = dm.GetMousePointWindow()
dm_ret = dm.BindWindow(hwnd, "dx2", "windows", "windows", 0)
//初始化跑图路径
Dim nn
nn=1
Rem 开始
Call 买物品()
Call 打宝箱()
Call 打身边怪()
Call 捡身边物()
Call 打半屏怪()
Delay 1000
Call 捡全屏物()
Call 打全屏怪()
Call 找怪()
Call 跑图()
Goto 开始
Sub 打宝箱()
dm_ret = dm.FindStrFast(0, 0, 800, 438, "宝|箱", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.KeyPress 113
Delay 1500
Goto 开始
End If
End Sub
Sub 打身边怪()
//身边怪物(名字判断)
dm_ret = dm.FindStrFast(279,119,508,294, "恶|灵", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo 390, 230
Delay 20
dm.KeyPress 113
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
Goto 开始
End If
End Sub
Sub 打半屏怪()
//半屏怪物(名字判断)
dm_ret = dm.FindStrFast(155,76,661,358, "恶|灵", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 20
Delay 20
dm.KeyPress 113
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
Goto 开始
End If
End Sub
Sub 打全屏怪()
//全屏怪物(名字判断)
dm_ret = dm.FindStrFast(0, 0, 800, 438, "恶|灵", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 20
Delay 20
dm.KeyPress 113
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
dm.MoveToEx 20, 400, 5, 5
Delay 500
Goto 开始
End If
End Sub
Sub 捡身边物()
//身边物品
dm_ret = dm.FindStrFast(213,63,574,354, "神|强|金", "ff0000-000000|ffffff-000000|88ddee-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 20
Delay 200
dm.LeftClick
Delay 100
dm.MoveToEx 20, 400, 5, 5
Delay 100
dm.MoveToEx 20, 400, 5, 5
Delay 700
Goto 开始
End If
End Sub
Sub 捡全屏物()
//全屏物品
dm_ret = dm.FindStrFast(0, 0, 800, 438, "神|强|金", "ff0000-000000|ffffff-000000|88ddee-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 20
Delay 200
dm.LeftClick
Delay 100
dm.MoveToEx 20, 400, 5, 5
Delay 100
dm.MoveToEx 20, 400, 5, 5
Delay 700
Goto 开始
End If
End Sub
Sub 找怪()
//小地图找怪
dm_ret = dm.FindMultiColor(608,0,800,160,"ff0000","0|1|ff0000,0|2|ff0000,0|3|ff0000,1|1|ff0000",1.0,0,intX,intY)
If intX >= 0 and intY >= 0 Then
i=1
For 5
dm.MoveTo intX + i, intY + i
dm.RightClick
i = i + 1
Delay 100
Next
End If
Delay 1000
//判断是否有怪,有怪停止移动
dm_ret = dm.FindStrFast(0, 0, 800, 438, "恶|灵", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo 390, 230
Delay 20
dm.RightClick
Goto 开始
Else
For 3
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "恶|灵", "ffffff-000000", 1.0, intA, intB)
If intA >= 0 and intB >= 0 Then
dm.MoveTo 390, 230
Delay 20
dm.RightClick
Goto 开始
End If
Next
End If
End Sub
Sub 买物品()
hong = dm.Ocr(304, 425, 318, 440, "ffffff-000000", 1.0)
lan = dm.Ocr(346, 423, 366, 439, "ffffff-000000", 1.0)
suiji=dm.Ocr(517,424,536,438, "ffffff-000000", 1.0)
TracePrint "红:" & hong & "蓝:" & lan & "随机:" & suiji
If hong = 0 Then
Delay 1000
hong = dm.Ocr(304, 425, 318, 440, "ffffff-000000", 1.0)
If hong = 0 Then
Call 买红()
End If
End If
If lan = 0 Then
Delay 1000
lan = dm.Ocr(346, 423, 366, 439, "ffffff-000000", 1.0)
If lan = 0 Then
Call 买蓝()
End If
End If
If suiji = 0 Then
Delay 1000
suiji=dm.Ocr(517,424,536,438, "ffffff-000000", 1.0)
If suiji = 0 Then
Call 买随机()
End If
End If
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "440000", "1|0|993300,2|0|dd7700,3|0|ffaa00,4|0|eebb00", 1.0, 0, intX, intY)
If dm_ret = 0 Then
Call 买双倍()
End If
End Sub
Sub 买红()
dm.MoveTo 766,566
Delay 20
dm.LeftClick
Delay 2000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "金币区", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "金创药", "00ff00-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//加号
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "080000","0|1|f7de39,0|2|f7de39,0|3|080000,0|4|6b5239", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
TracePrint 123
dm.MoveTo intX-30,intY
Delay 200
dm.LeftClick
Delay 20
dm.KeyPress 48
End If
Delay 1000
//付费购买按钮
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "8c8439", "0|1|fff76b,0|2|efe763,0|3|efe763,0|4|efe763", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//确定按钮
dm_ret = dm.FindStrFast(0, 0, 800, 438, "确定", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
//打开背包
dm.MoveTo 693, 399
Delay 20
dm.LeftClick
Delay 1000
//解开红药
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "7b3118", "1|0|6b3118,2|0|6b3118,3|0|7b3118,4|0|942918", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
//修理装备
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "d6c6ad", "1|0|bda57b,2|0|efc68c,3|0|f7f7de,4|0|b5a594", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
dm.MoveToEx 20, 400, 5, 5
End Sub
Sub 买蓝()
dm.MoveTo 766,566
Delay 20
dm.LeftClick
Delay 2000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "金币区", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "魔法药", "00ff00-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//加号
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "080000","0|1|f7de39,0|2|f7de39,0|3|080000,0|4|6b5239", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
TracePrint 123
dm.MoveTo intX-30,intY
Delay 200
dm.LeftClick
Delay 20
dm.KeyPress 48
End If
Delay 1000
//付费购买按钮
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "8c8439", "0|1|fff76b,0|2|efe763,0|3|efe763,0|4|efe763", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//确定按钮
dm_ret = dm.FindStrFast(0, 0, 800, 438, "确定", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm.MoveTo 693, 399
Delay 20
dm.LeftClick
Delay 1000
//解开蓝药
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "104284", "1|0|291884,2|0|291884,3|0|215aa5,4|0|738cff", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "d6c6ad", "1|0|bda57b,2|0|efc68c,3|0|f7f7de,4|0|b5a594", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
dm.MoveToEx 20, 400, 5, 5
End Sub
Sub 买随机()
dm.MoveTo 766,566
Delay 20
dm.LeftClick
Delay 2000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "金币区", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "随机传送石", "00ff00-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "8c8439", "0|1|fff76b,0|2|efe763,0|3|efe763,0|4|efe763", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//确定按钮
dm_ret = dm.FindStrFast(0, 0, 800, 438, "确定", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm.MoveTo 693, 399
Delay 20
dm.LeftClick
Delay 1000
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "d6c6ad", "1|0|bda57b,2|0|efc68c,3|0|f7f7de,4|0|b5a594", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
dm.MoveToEx 20, 400, 5, 5
End Sub
Sub 买双倍()
dm.MoveTo 766,566
Delay 20
dm.LeftClick
Delay 2000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "金币区", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "双倍秘籍", "00ff00-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm_ret = dm.FindMultiColor(0, 0, 800, 438, "8c8439", "0|1|fff76b,0|2|efe763,0|3|efe763,0|4|efe763", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
//确定按钮
dm_ret = dm.FindStrFast(0, 0, 800, 438, "确定", "efd6ad-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX + 20, intY + 10
Delay 20
dm.LeftClick
End If
Delay 1000
dm.MoveTo 693, 399
Delay 20
dm.LeftClick
Delay 1000
dm_ret = dm.FindMultiColor(0, 0, 800, 600, "ce3129", "0|1|ff5a5a,0|2|ff5a5a,0|3|d65a52,0|4|ce3129", 1.0, 0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo intX, intY
Delay 2000
dm.RightClick
Delay 2000
End If
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
Delay 1000
dm.KeyPress 27
dm.MoveToEx 20, 400, 5, 5
End Sub
Sub 自动()
dm.KeyDown 17
Delay 20
dm.KeyPress 76
Delay 20
dm.KeyUp 17
End Sub
Sub 跑图()
zuobiao = dm.Ocr(68,583,129,599, "ffffff-000000", 1.0)
zuobiaox = mid(zuobiao,1,instr(zuobiao, ":")-1)
zuobiaoy = mid(zuobiao, instr(zuobiao, ":") + 1, 3)
If 86 > zuobiaox > 76 and 43 > zuobiaoy > 33 Then
nn=2
ElseIf 53 > zuobiaox > 43 and 33 > zuobiaoy > 22 Then
nn = 3
ElseIf 25 > zuobiaox > 15 and 60 > zuobiaoy > 50 Then
nn = 4
ElseIf 65 > zuobiaox > 55 and 87 > zuobiaoy > 77 Then
nn = 1
End If
Select case nn
Case 1
dm.MoveTo 750, 68
Delay 20
dm.RightClick
Delay 1000
Case 2
dm.MoveTo 700, 57
Delay 20
dm.RightClick
Delay 1000
Case 3
dm.MoveTo 659, 85
Delay 20
dm.RightClick
Delay 1000
Case 4
dm.MoveTo 720, 112
Delay 20
dm.RightClick
Delay 1000
End Select
//判断是否有怪,有怪停止移动
dm_ret = dm.FindStrFast(0, 0, 800, 438, "恶|灵|宝|箱", "ffffff-000000", 1.0, intX, intY)
If intX >= 0 and intY >= 0 Then
dm.MoveTo 390, 230
Delay 20
dm.RightClick
Goto 开始
Else
For 3
Delay 1000
dm_ret = dm.FindStrFast(0, 0, 800, 438, "恶|灵", "ffffff-000000", 1.0, intA, intB)
If intA >= 0 and intB >= 0 Then
dm.MoveTo 390, 230
Delay 20
dm.RightClick
Goto 开始
End If
Next
End If
End Sub