2013-12-09 40 views
0

我一直在试图做一个自动选择器的研磨,但它只是停在中间,我不明白为什么。这是我到目前为止:函数不返回一个变量的自动热键定义

^!n:: ;Ctr+Alt+n 
FindColour(0x4447FB, 338, 491) ; Enter Building 
Sleep 1500 
FindColour(0x4145F1, 387, 420) ; Left Attack 
Battle(1,1,1,1,0) 
Sleep 1500 
FindColour(0x4447FB, 602, 335) ; Far Attack 
; Do Attack 
Sleep 1500 
FindColour(0x4447FC, 555, 527) ; Bottom Attack 
; Do Attack 
Sleep 1500 
FindColour(0x4347FB, 338, 537) ; Leave Building 
Sleep 1500 
FindColour(0xF9F9F5, 239, 561) ; Reset Point 
Sleep 1500 
Return 

FindColour(Colour, x, y){ ; Wait until the correct colour appears before clicking 
Col = 0x000000 
MouseMove, %x%, %y% 
Loop 
{ 
PixelGetColor, Col, %x%, %y% 
If Col = %Colour% 
{ 
    Click %x% %y% 
    Return 
} 
Sleep 10 
} 
Return 
} 

Battle(a, b, c, d, e){ ; e isn't needed yet 
x = 488 
y := FindStart() 
Col = 0x3F18D0 
MsgBox %y% 

Loop %a% 
{ 
FindColour(%Col%, %x%, %y%) 
Sleep 100 
Click 606 276 
} 

Loop %b% 
{ 
FindColour(%Col%, %x%, %y%) 
Sleep 100 
Click 547 371 
} 

Loop %c% 
{ 
FindColour(%Col%, %x%, %y%) 
Sleep 100 
Click 676 491 
} 

Loop %d% 
{ 
FindColour(%Col%, %x%, %y%) 
Sleep 100 
Click 774 309 
} 

; End 

Return 
} 

FindStart(){ 
x = 488 
y = 200 
Loop 300 
{ 
MouseMove, %x%, %y% 
Sleep 20 
PixelGetColor, Col, %x%, %y% 
If Col = 0x3D00FF 
{ 
    y += 23 
    Return %y% 
} 
Else 
{ 
    y += 1 
} 
} 
MsgBox Start not found 
} 

它运行得很好,直到它运行FindStart()。我看着光标缓慢地沿着屏幕向下移动到正确的像素(移动每场战斗,从而移动功能),然后停止。在调用FindStart()之后,我放置了“MsgBox%y%”这一行,以检查函数调用后发生的任何事情,但msgbox从不出现。

我错过了什么?

+0

准确找出停车位置。双击脚本的托盘图标将显示最近执行的行。 – MCL

回答

1

我找到了解决方案。事实证明,调用函数时发送的变量不应包含在百分号中。