2
我正嘗試使用imagesearch從遊戲中的某個商品店購買某些物品。有8個插槽,因此我需要循環8次。如果他們出現,我需要購買4-5種不同的物品。Autohotkey如何使用函數參數來執行多個imageSearches
這是我用做購買功能:
marketFunc(item)
{
Loop, 8
{
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, item
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
}
}
我則一直在呼籲這樣的功能:
marketfunc(chip.png)
sleep, 500
marketfunc(ticket.png)
sleep, 500
marketfunc(scroll.png)
sleep, 500
marketfunc(masterScroll.png)
sleep, 500
marketfunc(otherItemHere.png)
我知道我能做到這一點沒有的功能等這個:
Loop, 8
{
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, ticket.png
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, chip.png
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, scroll.png
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, masterScroll.png
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
ImageSearch, OutputVarX, OutputVarY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, otherItemHere.png
if !ErrorLevel
{
outY = %OutputVarY%
outY += 119
MouseMove, %OutputVarX%, %OutY%
Sleep, 250
Click
Sleep, 750
MouseClick, left, 797, 456
Sleep, 750
MouseClick, left, 687, 473
Sleep, 100
}
Sleep, 250
}
但是我不喜歡它的外觀,它感覺太硬code-y。
任何幫助將appriciated。
我忘記提及實際問題了。當我運行它時,它使用我的函數方法時找不到圖像。但是,當我使用下面的例子它可以正常工作。所以我假設我設置了函數參數錯誤。 –