Autohotkey 函数不返回自动热键定义的变量 我一直在尝试用自动点击器进行研磨,但是它正好停在中间,我不明白为什么。以下是我目前掌握的情况: ^!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 }

Autohotkey 函数不返回自动热键定义的变量 我一直在尝试用自动点击器进行研磨,但是它正好停在中间,我不明白为什么。以下是我目前掌握的情况: ^!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 },autohotkey,Autohotkey,在运行FindStart()之前,一切正常。我看着光标慢慢地沿着屏幕向下移动到正确的像素点(这会移动每一场战斗,从而移动函数),此时光标停止。我在调用FindStart()后放置了行“MsgBox%y%”,以检查调用函数后发生的任何情况,但MsgBox从未出现 我错过了什么 我找到了解决办法。事实证明,调用函数时发送的变量不应该用百分号括起来。找出函数的确切停止位置。双击脚本的托盘图标将显示最近执行的行。

在运行FindStart()之前,一切正常。我看着光标慢慢地沿着屏幕向下移动到正确的像素点(这会移动每一场战斗,从而移动函数),此时光标停止。我在调用FindStart()后放置了行“MsgBox%y%”,以检查调用函数后发生的任何情况,但MsgBox从未出现


我错过了什么

我找到了解决办法。事实证明,调用函数时发送的变量不应该用百分号括起来。

找出函数的确切停止位置。双击脚本的托盘图标将显示最近执行的行。