第一个子程序运行中途,我赋值一个数组数据给下一个我子程序用。我测试的时候,卡在第一For那不出来。是我卡BUG了,还是我的用法错误。感觉像是子程序里面调子程序在调子程序,数据好像不传递一样。 f2 = Array(Form1.InputBox48.Text, Form1.InputBox47.Text, Form1.InputBox46.Text, Form1.InputBox45.Text) Sub 子程序1 f3=f2 d5 = 0 f4 = intX4 Call 子程序2 if f4>0 then …… …… End Sub Sub 子程序2 i=0 For 10 Delay 100 KeyPress 48, 1 Delay 100 Call 子程序3 If intX1 > 0 Then TracePrint "找到货船" Exit For Else TracePrint "找不到货船" If i = 5 Then MessageBox "找不到货船" ExitScript End If i = i + 1 End If Next If d5 > 0 Then KeyPress d5, 1 End If If f3(0) > 0 Then MoveTo f3(0), f3(1) Delay d1 LeftClick 1 Delay d2 End If MoveTo f3(2), f3(3) Delay d1 LeftClick 1 Delay d2 Do Call 子程序3 If f4 > 0 Then TracePrint "到了" Exit Do End If Delay d3 Loop End sub Sub 子程序3 FindPic 1672,654,1827,723, "Attachment:\地图1.bmp", 0.9, intX1, intY1 FindPic 1672,654,1827,723, "Attachment:\地图2.bmp", 0.9, intX2, intY2 FindPic 1672,654,1827,723, "Attachment:\地图3.bmp", 0.9, intX3, intY3 FindPic 1672,654,1827,723, "Attachment:\地图4.bmp", 0.9, intX4, intY4 End Sub
大佬帮我封装一个多点找色函数,下面是我封装的找图函数,跟这个一样用就行 Function 找图(x1, y1, x2, y2, 图片名, 相似度) dim IntX,intY FindPic x1, y1, x2, y2, "Attachment:" & 图片名 & ".png", "050505", 0,相似度, IntX, intY //如果没有找到,intX和intY的值都会被置为-1 If IntX > -1 And IntY > -1 Then Delay 500 找图 = True End If End Function 下面是按键给的多点找色参数,不会封装,哈哈 Dim IntX,IntY FindMultiColor 0,0,0,0,"FFFFFF","4|1|2F9772-000000|123456-101010,3|7|378757",0,0.9,intX,intY If intX > -1 Then TracePrint "找到啦,坐标在"&intX&","&intY Else TracePrint "没找到" End If