给自己玩的游戏写了个辅助,有些不懂的地方,求助
vb6.0吧
全部回复
仅看楼主
level 5
云亦驻足 楼主
如图1,可以运行,用的大漠插件。我想控制第二个号,如图2,不知道怎么写了,能提供下思路吗?以前在按键精灵里用多线程,但是不稳定。
图1
图2
Dim dm As New dmsoft
Dim x_jiaose As Integer
Dim y_jiaose As Integer
Dim x_weizhi As Integer
Dim y_weizhi As Integer
Dim hwnde As Long
Dim dt As String
Dim cfd As Integer
Dim lhsrw As Integer
Dim cfx As Integer
Dim cfy As Integer
Option Explicit
Private Sub cmd_Click()
If cmd.Caption = "运行" Then
cmd.Caption = "退出"
Else
End
End If
Dim dm_ret As Integer
dm.SetPath "c:\test_game"
If chk.Value = 1 Then
hwnde = dm.ReadIni("句柄", "暖阳", "句柄.ini") '读取句柄
dm_ret = dm.BindWindow(hwnde, "gdi", "dx2", "dx", 0) '绑定窗口
Yanshi (1000)
dm.MoveTo 400, 300
Else
Call 开号
Yanshi (200)
Call 账号1
dm.MoveTo 946, 603
Yanshi (10)
dm.LeftClick
Yanshi (12000)
x_jiaose = 718
y_jiaose = 546
x_weizhi = 630
y_weizhi = -22
Call 角色界面
hwnde = dm.GetMousePointWindow()
dm.WriteIni "句柄", "暖阳", hwnde, "句柄.ini"
dm.MoveWindow hwnde, x_weizhi, y_weizhi
Yanshi (500)
dm_ret = dm.BindWindow(hwnde, "gdi", "dx2", "dx", 0)
Call 关聊天窗口
End If
'调用字库,此函数速度很慢,全局初始化时调用一次即可,切换字库用UseDict
dm_ret = dm.SetDict(0, "lianhua.txt")
Dim ii As Integer
ii = 0
Do While ii = 0
DoEvents '操作权交给系统
Call 判断任务
If lhsrw = 0 Then
Call 去北郡
Call 炼化师任务
Else
If lhsrw = 1 Then
Call 去轩辕
Call 去打怪
End If
End If
Loop
End Sub
2017年02月24日 13点02分 1
level 5
云亦驻足 楼主
Private Sub 去北郡()
Dim dm_ret As Integer
Dim xx As Integer
Dim ll As String
Dim intx
Dim inty
Do
DoEvents '操作权交给系统
Call 车夫坐标
If dt = "北" Then
Else
去车夫:
xx = dm.FindStr(162, 7, 672, 473, "驿", "ff8a00-000000", 1, intx, inty)
If intx > 0 Then
dm.MoveTo intx + 25, inty + 30
Yanshi (20)
dm.RightClick
Yanshi (1000)
Call 右键窗口等待
dm.MoveTo 400, 300
If cfd = 0 Then
cfd = 10
GoTo 去车夫
End If
dm_ret = dm.FindStr(570, 240, 586, 387, "北", "ffff00-000000", 1#, intx, inty)
If intx >= 0 And inty >= 0 Then
dm.MoveTo intx, inty + 5
Yanshi (20)
dm.LeftClick
Yanshi (500)
'北郡一到八
Dim bjy_sj As Integer
Randomize '初始化随机数生成器。
bjy_sj = Int((118 * Rnd) + 244) ' 产生244到362随机数
dm.MoveTo 592, bjy_sj
Yanshi (20)
dm.LeftClick
Call 过地图
'到北郡了
Else
dm_ret = dm.FindStr(570, 240, 586, 387, "天", "ffff00-000000", 1, intx, inty)
If intx >= 0 And inty >= 0 Then
dm.MoveTo intx, inty + 5
Yanshi (20)
dm.LeftClick
Call 过地图
'到天圣元了
End If
End If
Else
dm.KeyPress 9
Yanshi (800)
'加个判断
Do
DoEvents '操作权交给系统
ll = dm.GetColor(787, 10)
If ll = "c60000" Then
dm.MoveTo cfx, cfy
Yanshi (20)
dm.LeftClick
Yanshi (500)
dm.KeyPress 9
Yanshi (2000)
Else
dm.KeyPress 9
Yanshi (800)
End If
Loop Until ll = "c60000"
GoTo 去车夫
End If
End If
Loop Until dt = "北"
End Sub
Private Sub 去轩辕()
Dim xx As Integer
Dim dm_ret As Integer
Dim ll As String
Dim intx
Dim inty
Do
DoEvents '操作权交给系统
Call 车夫坐标
If dt = "轩" Then
Else
去车夫:
xx = dm.FindStr(162, 7, 672, 473, "驿", "ff8a00-000000", 1#, intx, inty)
If intx >= 0 Then
dm.MoveTo intx + 25, inty + 30
Yanshi (20)
dm.RightClick
Yanshi (1000)
Call 右键窗口等待
dm.MoveTo 400, 300
If cfd = 0 Then
cfd = 10
GoTo 去车夫
End If
dm_ret = dm.FindStr(570, 240, 586, 387, "轩", "ffff00-000000", 1#, intx, inty)
If intx >= 0 And inty >= 0 Then
dm.MoveTo intx, inty + 5
Yanshi (20)
dm.LeftClick
Call 过地图
'到轩辕了
Else
dm_ret = dm.FindStr(570, 240, 586, 387, "天", "ffff00-000000", 1#, intx, inty)
If intx >= 0 And inty >= 0 Then
dm.MoveTo intx, inty + 5
Yanshi (20)
dm.LeftClick
Call 过地图
'到天圣元了
End If
End If
Else
dm.KeyPress 9
Yanshi (800)
'加个判断
Do
DoEvents '操作权交给系统
ll = dm.GetColor(787, 10)
If ll = "c60000" Then
dm.MoveTo cfx, cfy
Yanshi (20)
dm.LeftClick
Yanshi (500)
dm.KeyPress 9
Yanshi (2000)
Else
dm.KeyPress 9
Yanshi (800)
End If
Loop Until ll = "c60000"
GoTo 去车夫
End If
End If
Loop Until dt = "轩"
End Sub
2017年02月24日 13点02分 3
level 5
云亦驻足 楼主
Private Sub 判断任务()
Dim n As Integer
Dim lh As String
Dim rw As String
n = 10
'按V键
dm.KeyPress 86
Yanshi (100)
'等待任务日志对话框出现
Do
DoEvents '操作权交给系统
lh = dm.GetColor(48, 112)
Yanshi (200)
n = n - 1
If n = 0 Then
'MsgBox "重新按V"
dm.KeyPress 86
Yanshi (100)
End If
Loop Until lh = "fff7ce"
'判断有没有任务
rw = dm.GetColor(27, 161)
If rw = "fff7ce" Then
'有任务
rw = dm.GetColor(175, 161)
If rw = "fff7ce" Then
'按V键
dm.KeyPress 86
'完成任务了
lhsrw = 0
'msgbox "去炼化师"
Else
'按V键
dm.KeyPress 86
'没完成
lhsrw = 1
'msgbox "去任务地点"
End If
Else
'没有任务
lhsrw = 0
'按V键
dm.KeyPress 86
End If
End Sub
Private Sub 炼化师任务()
Dim t1 As Long
Dim dm_ret As Integer
Dim s As String
Dim ll As String
Dim intx
Dim inty
t1 = 10000
炼化师:
'查找炼化师
dm_ret = dm.FindStr(162, 7, 672, 473, "炼化", "ff8a00-000000", 1#, intx, inty)
If intx >= 0 And inty >= 0 Then
dm.MoveTo intx + 45, inty + 80
Yanshi (20)
dm.RightClick
Yanshi (500)
Call 右键窗口等待
If cfd = 0 Then
cfd = 10
GoTo 炼化师
End If
s = dm.Ocr(532, 358, 565, 408, "ffff00-000000", 1#)
If s = "接受" Then
dm.MoveTo 565, 382
Yanshi (20)
'接受任务
dm.LeftClick
Else
If s = "完成" Then
dm.MoveTo 565, 393
Yanshi (20)
'完成任务
dm.LeftClick
Yanshi (50)
'点一下自己,让对话框消失
dm.MoveTo 400, 300
dm.LeftClick
Yanshi (200)
Call 等对话框消失
GoTo 炼化师
Else
'都不对则是接了任务还没完成
'msgbox "去完成任务吧"
End If
End If
Else
'按下tab键,点击炼化师
dm.KeyPress 9
Yanshi (800)
'加个判断
Do
DoEvents '操作权交给系统
ll = dm.GetColor(787, 10)
If ll = "c60000" Then
Else
dm.KeyPress 9
Yanshi (800)
End If
Loop Until ll = "c60000"
dm.MoveTo 263, 153
Yanshi (20)
dm.LeftClick
dm.KeyPress 9
Yanshi (500)
'后面两秒循环一次
If t1 > 2000 Then
Yanshi (t1)
t1 = t1 - 8000
Else
Yanshi (t1)
End If
GoTo 炼化师
End If
End Sub
Private Sub 右键窗口等待()
Dim n As Integer
n = 10
Dim m As String
Do While m <> "efe384"
DoEvents '操作权交给系统
m = dm.GetColor(696, 478)
Yanshi (500)
n = n - 1
cfd = n
If n = 0 Then
m = dm.GetColor(529, 196)
If m = "efe384" Then
cfd = n
dm.MoveTo 529, 196
Yanshi 50
dm.LeftClick
Exit Do
Else
'END键向车夫靠近
dm.KeyPress 35
Yanshi (100)
dm.KeyPress 35
Yanshi (1500)
cfd = n
Exit Do
End If
End If
Loop
End Sub
Private Sub 等对话框消失()
Dim m As String
Dim n As Integer
n = 10
Do
DoEvents '操作权交给系统
m = dm.GetColor(696, 478)
Yanshi (500)
n = n - 1
If n = 0 Then
MsgBox "对话框没消失"
End If
Loop While m = "efe384"
End Sub
Private Sub 车夫坐标()
坐标开始:
'判断当前地图
dt = dm.Ocr(641, 2, 658, 18, "ffff94-000000", 1#)
If dt = "天" Then
Call 天圣元车夫选择
Else
If dt = "轩" Then
cfx = 188
cfy = 441
Else
If dt = "北" Then
cfx = 202
cfy = 130
Else
MsgBox "未知地图,回天或北郡再点确认!"
GoTo 坐标开始
End If
End If
End If
End Sub
Private Sub 天圣元车夫选择()
Dim s As Integer
dm.MoveTo 400, 300
'yanshi() 20
'dm.LeftClick
Yanshi (300)
s = dm.Ocr(737, 2, 765, 17, "ffff94-000000", 1#) '得到人物X坐标
If Abs(s - 203) <= 8 Then '上方车夫
cfx = 463 '上方车夫坐标
cfy = 342
Else
If Abs(s - 172) <= 8 Then '下方车夫
cfx = 393
cfy = 406
Else
If Abs(s - 144) <= 8 Then '左面车夫
cfx = 328
cfy = 374
Else
'都不靠近的话到下方车夫
cfx = 393
cfy = 406
End If
End If
End If
End Sub
Private Sub 过地图()
Yanshi (2500)
Dim m As Integer
Dim n As String
m = 10
n = ""
Do While n <> "fff7ce"
DoEvents '操作权交给系统
n = dm.GetColor(596, 6)
Yanshi (1000)
m = m - 1
If m = 0 Then
MsgBox "卡地图了" '以后做成微信报警
'退出循环
Exit Do
End If
Loop
End Sub
2017年02月24日 13点02分 4
level 11
[呵呵]
2017年02月28日 16点02分 5
1