Bored at work today, so I made a new & improved AutoIt script utilizing
_ImageSearch.
I've tested this on a variety of resolutions from 1024x764 to 1680x1050 and it seems to work on most of them.
Start the script, open both WoW Windows, and have them both on Alt+Tab, where the character that's supposed to win is in the topmost/active window.
Press F8 to let the script start working, while F9 to stop it.
Window titles are changed at the start, and used instead of tabbing back and forth, for increased stability.
This script uses 4 different images to locate Find, Accept, First Pet & Forfeit, and you'll have to replace these if it doesn't work out of the box.
I'm in fact pretty sure you have to replace pet.bmp as it searches for my Robo-Chick.
Worth to note is that the script clicks in the center of the image.
The macro/wow script to enable one-click forfeits are automatically run, but just in case, here it is:
Code:
/run PetBattleFrame.BottomFrame.ForfeitButton:SetScript("OnClick", function() C_PetBattles.ForfeitGame() end)
Full bundle with everything you need, can be found
-> here <-.
The script:
Code:
#include
HotKeySet("{F9}", "ExitProg")
HotKeySet("{F8}", "StartStop")
Func ExitProg()
$Go = False
Sleep(100)
WinActivate("WoW-Win")
Sleep(500)
WinSetTitle("WoW-Win", "", "World of Warcraft")
Sleep(100)
WinActivate("WoW-Lose")
Sleep(500)
WinSetTitle("WoW-Lose", "", "World of Warcraft")
Sleep(100)
Exit 0
EndFunc
$Go = False
$Step = 0
$SubStep = 0
#Find button
$FB_X=0
$FB_Y=0
#Accept button
$AB_X=0
$AB_Y=0
#First Pet
$FP_X=0
$FP_Y=0
#Forfeit flag
$FF_X=0
$FF_Y=0
While 1
While $Go = True
While $Step = 0
Sleep(500)
WinSetTitle("World of Warcraft", "", "WoW-Win")
Sleep(500)
Send("{ALTDOWN}{TAB}{ALTUP}")
Sleep(1000)
WinSetTitle("World of Warcraft", "", "WoW-Lose")
Sleep(100)
WinActivate("WoW-Lose")
Sleep(200)
Send("{ENTER}")
Sleep(500)
Send('/run PetBattleFrame.BottomFrame.ForfeitButton:SetScript("OnClick", function() C_PetBattles.ForfeitGame() end)')
Sleep(500)
Send("{ENTER}")
Sleep(500)
$Step = 1
WEnd
While $Step = 1
WinActivate("WoW-Win")
Sleep(100)
$Search = _ImageSearch('find.bmp', 1, $FB_X, $FB_Y, 100)
If $Search = 1 Then
MouseClick("left",$FB_X, $FB_Y,1)
Sleep(100)
MouseMove(0,0,1)
sleep(200)
$Step = 2
EndIf
WEnd
While $Step = 2
WinActivate("WoW-Lose")
Sleep(100)
$Search = _ImageSearch('find.bmp', 1, $FB_X, $FB_Y, 100)
If $Search = 1 Then
MouseClick("left",$FB_X, $FB_Y,1)
Sleep(100)
MouseMove(0,0,1)
sleep(200)
$Step = 3
EndIf
WEnd
While $Step = 3
WinActivate("WoW-Win")
Sleep(100)
$Search = _ImageSearch('accept.bmp', 1, $AB_X, $AB_Y, 100)
If $Search = 1 Then
MouseClick("left", $AB_X, $AB_Y, 1)
Sleep(100)
MouseMove(0,0,1)
Sleep(200)
$Step = 4
EndIf
WEnd
While $Step = 4
WinActivate("WoW-Lose")
Sleep(100)
$Search = _ImageSearch('accept.bmp', 1, $AB_X, $AB_Y, 100)
If $Search = 1 Then
MouseClick("left", $AB_X, $AB_Y, 1)
Sleep(100)
MouseMove(0,0,1)
Sleep(200)
$Step = 5
EndIf
WEnd
While $Step = 5
WinActivate("WoW-Win")
Sleep(100)
$Search = _ImageSearch('pet.bmp', 1, $FP_X, $FP_Y, 100)
If $Search = 1 Then
MouseClick("left", $FP_X, $FP_Y, 1)
Sleep(100)
MouseMove(0,0,1)
Sleep(200)
$Step = 6
EndIf
WEnd
While $Step = 6
WinActivate("WoW-Lose")
Sleep(100)
$Search = _ImageSearch('forfeit.bmp', 1, $FF_X, $FF_Y, 100)
If $Search = 1 Then
MouseClick("left", $FF_X, $FF_Y, 1)
Sleep(100)
MouseMove(0,0,1)
Sleep(2500)
$Step = 7
EndIf
WEnd
While $Step = 7
WinActivate("WoW-Lose")
Sleep(100)
$Search = _ImageSearch('find.bmp', 1, $FB_X, $FB_Y, 80)
If $Search = 1 Then
Sleep(500)
$Step = 1
EndIf
WEnd
WEnd
WEnd
Func StartStop()
If $Go = False Then
$Go = True
Else
$Go = False
EndIf
EndFunc
(Sorry for messy post, writing this stuff through Splashtop).