The Bytecode Club
Log inJoin the club
Video Game Reverse Engineering

Developing Bot

Started by Antidote · Dec 5, 2014

1,033 replies21,297,466 viewsLocked
Dec 12, 2014#41

How to get the GUI antidote. otherwise working Great!

Dec 12, 2014#42

Anyone can make a tool that can auto searching gold/elixir with condition on Bluestack app. And auto-stop when the condition is true. I only need that feature. Thank you 🙂

Dec 12, 2014#43

@qaqaq: you can use this one I'm working on, I strip out all other unfinished function and keep the search function only. Just unrar the file then go to the folder and open Search Function. I tested on a different machine with no Tesseract or Autoit installed and it works fine. Recommended resolution is 800x600 or 860x720 as I fine tune reading for that. Click on the reg file to change your resolution and restart BlueStacks. To use the search function, just go to your village, zoom out max, click attack then open the program, input your desired gold and elixir and click Start. It will skip through village until it find your match and display message in the task bar. If you don't want that target, click Start again and it will continue searching. However this is supposed for testing only as the reading's accuracy is not 100%, especially after the Christmas update (wonder if the white snow screw up Tesseract lol). But the worst is it miss out a few village or fault positive so no big deal..
Link: https://mega.co.nz/#!809iCRAK!7Oh0hmkhwKlL1XGZ3U1CcMZeMSFx0LlRpI8lzR5orQs

Dec 12, 2014#44

is it possible you can send it to me? my computer doesn't "like" mega and wont download it for me!

Dec 12, 2014#45

I reupload to zippyshare for you
Search Function. rar
http://www38.zippyshare.com/v/81492639/file.html
Bot.rar
http://www38.zippyshare.com/v/76107874/file.html
Bot.rar is the one with all the function I'm working on. For now it will ask user to click on barrack to register its position, then train troop according to user's input and start attack. At the moment it will drop troop as follow: drop troop at the third position first (giant), then first position (barbarian), then second (archer). This is because I train only barbarian, archer and giant for raiding. I'm working to get it to detect which troop is at which position when attacking with different army composition. Next week's quite busy for me so hope anyone can get to the code and improve it. I'm new to Autoit so the code's quite messy lol
Here's the code for those interested:
http://pastebin.com/nPRfLWBg

#RequireAdmin
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <TrayConstants.au3>
#include <Misc.au3>
#include <Tesseract.au3>
 
Opt ("MouseClickDelay", 10)
Opt ("MouseClickDownDelay", 10)
Opt ("MouseCoordMode", 0)
Opt ('PixelCoordMode', 0)
 
$Title = "BlueStacks App Player"
$Full = WinGetTitle ($Title)
$HWnD = WinGetHandle ($Full)
WinActivate ($HWnD)
 
Global $Left = 45, $Top = 70, $Right = 660, $Bottom = 490
Global $BSsize = WinGetClientSize($hWnd)
Global $x_ratio = $BSsize[0]/800, $y_ratio = $BSsize[1]/600
 
Global $Gold, $Elixir, $MinGold = 50000, $MinElixir = 50000
Global $SearchMode = 1, $SearchCheck = 0, $ErrorCheck = 0
 
Global $UpLeft[5][2] = [[350*$x_ratio,51*$y_ratio],[230*$x_ratio,100*$y_ratio],[186*$x_ratio,160*$y_ratio],[144*$x_ratio,187*$y_ratio],[125*$x_ratio,200*$y_ratio]]
Global $UpRight[5][2] = [[460*$x_ratio,62*$y_ratio],[520*$x_ratio,97*$y_ratio],[570*$x_ratio,134*$y_ratio],[647*$x_ratio,186*$y_ratio],[692*$x_ratio,211*$y_ratio]]
Global $LowLeft[5][2] = [[77*$x_ratio, 306*$y_ratio],[130*$x_ratio,353*$y_ratio],[181*$x_ratio,395*$y_ratio],[214*$x_ratio,415*$y_ratio],[250*$x_ratio,442*$y_ratio]]
Global $LowRight[5][2] = [[734*$x_ratio,290*$y_ratio],[685*$x_ratio,318*$y_ratio],[630*$x_ratio,350*$y_ratio],[600*$x_ratio,369*$y_ratio],[535*$x_ratio,425*$y_ratio]]
 
Global $Troop[5][2] = [[60*$x_ratio,505*$y_ratio],[130*$x_ratio,505*$y_ratio],[200*$x_ratio,505*$y_ratio],[265*$x_ratio,505*$y_ratio],[372*$x_ratio,505*$y_ratio]]
Global $Barbarian[2] = [0,0], $Archer[2] = [0,0], $Golbin[2] =[0,0], $Giant[2] = [0,0]
 
Global $B1Pos[2] = [0,0], $B2Pos[2] = [0,0], $B3Pos[2] = [0,0], $B4Pos[2] = [0,0]
Global $B1Troop, $B2Troop, $B3Troop, $B4Troop
 
HotKeySet("+{ESC}","Terminate")
 
#Region ### GUI ###
$BotGUI = GUICreate("Clash of Clans Bot", 280, 170)
GUICtrlSetFont(-1, 10, 800, 0, "Calibri")
$MeetAll = GUICtrlCreateCheckbox("Meet all conditions", 150, 20, 140, 17)
GUICtrlCreateLabel("Min Gold:", 150, 48, 58, 17)
$MinGoldInput = GUICtrlCreateInput("", 200, 44, 55, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 6)
GUICtrlCreateLabel("Min Elixir:", 150, 72, 57, 17)
$MinElixirInput = GUICtrlCreateInput("", 200, 68, 55, 21, $ES_NUMBER)
GUICtrlSetLimit(-1, 6)
$Barrack01 = GUICtrlCreateCombo("Barrack 01", 30, 16, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
$Barrack02 = GUICtrlCreateCombo("Barrack 02", 30, 40, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
$Barrack03 = GUICtrlCreateCombo("Barrack 03", 30, 64, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
$Barrack04 = GUICtrlCreateCombo("Barrack 04", 30, 88, 80, 30, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Barbarian|Archer|Goblin|Giant")
$StartButton = GUICtrlCreateButton("START (Shift+ESC to Exit)", 30, 120, 220, 40)
GUISetState(@SW_SHOW)
#EndRegion ### GUI ###
 
While 1
   $Msg = GUIGetMsg()
   Switch $Msg
          Case $GUI_EVENT_CLOSE
                 $ExitCheck = MsgBox(4+65536, "Confirm Exit", "Are you sure you want to exit?", 0, $BotGUI)
                 If $ExitCheck = 6 Then
                        Exit
                 EndIf
          Case $StartButton
                 Start()
   EndSwitch
 WEnd
 
Func Start()
   Sleep(1000)
   ;While 1
          CheckIdle()   ;Check disconnect message and click on reload
          GetInput()    ;Read user's input
          ZoomOut()
          LocateBarrack()       ;If barrack not located, ask user to manually click on barrack to locate position
          Train()                       ;Train troop according to user's input
          ;Sleep(900000)        ;Wait 15 mins for troops training
          ;AssignTroop()        ;Assign troop type to troop position in attack (unfinished)
          PrepareAttack()       ;Click Attack
          VillageSearch()       ;Search gold & elixir according to input
          ;DropTroop()  ;Drop troop in order: Giant, Barbarian, Archer (unfinished)
          DropAll()     ;Drop everything
          Sleep(180000) ;Wait 3 mins
          ControlClick ($HWnD, "","", "left", "1", 400*$x_ratio, 450*$y_ratio)  ;Click Return Home
          ;Sleep(10000)
   ;WEnd
EndFunc
 
Func CheckIdle()
   WinActivate($HWnD)
   $ColorCheck = PixelGetColor(560*$x_ratio, 333*$y_ratio, $HWnD)
   If Hex($ColorCheck,6) = 282828 Then
          ControlClick ($HWnD, "","", "left", "1", 205*$x_ratio, 330*$y_ratio)
          Sleep(10000)
   EndIf
EndFunc
 
Func GetInput()
   $B1Troop = GUICtrlRead($Barrack01)
   $B2Troop = GUICtrlRead($Barrack02)
   $B3Troop = GUICtrlRead($Barrack03)
   $B4Troop = GUICtrlRead($Barrack04)
   $MinGold = Number(GUICtrlRead($MinGoldInput))
   $MinElixir = Number(GUICtrlRead($MinElixirInput))
   If GUICtrlRead($MeetAll) = $GUI_CHECKED Then
          $SearchMode = 2
   Else
          $SearchMode = 1
   EndIf
EndFunc
 
#Region ##### TRAIN #####
Func FindPos(ByRef $Pos)
   Local $x = 1
          While $x = 1
                 If _IsPressed("01") Then
                        $Pos = MouseGetPos()
                        $x = 0
                 EndIf
          WEnd
   EndFunc
 
Func LocateBarrack()
   Local $ClickCheck, $LocateCheck = 0
   While 1
          While 1
                 If $B1Pos[0] = 0 Then
                        $ClickCheck = MsgBox(6+65536, "Locate first barrack", "Click Continue then click on your first barrack. Cancel if not available", 0, $BotGUI)
                        If $ClickCheck = 11 Then
                           WinActivate ($HWnD)
                           FindPos($B1Pos)
                        ElseIf $ClickCheck = 10 Then
                           $B1Pos[0] = 0
                           $B2Pos[0] = 0
                           $B3Pos[0] = 0
                           $B4Pos[0] = 0
                           ExitLoop
                        EndIf
                        Sleep(500)
                 EndIf
 
                 If $B2Pos[0] = 0 Then
                        $ClickCheck = MsgBox(6+65536, "Locate second barrack", "Click Continue then click on you second barrack. Cancel if not available", 0, $BotGUI)
                        If $ClickCheck = 11 Then
                           WinActivate ($HWnD)
                           FindPos($B2Pos)
                        ElseIf $ClickCheck = 10 Then
                           $B1Pos[0] = 0
                           $B2Pos[0] = 0
                           $B3Pos[0] = 0
                           $B4Pos[0] = 0
                           ExitLoop
                        EndIf
                        Sleep(500)
                 EndIf
 
                 If $B3Pos[0] = 0 Then
                        $ClickCheck = MsgBox(6+65536, "Locate third barrack", "Click Continue then click on your third barrack. Cancel if not available", 0, $BotGUI)
                        If $ClickCheck = 11 Then
                           WinActivate ($HWnD)
                           FindPos($B3Pos)
                        ElseIf $ClickCheck = 10 Then
                           $B1Pos[0] = 0
                           $B2Pos[0] = 0
                           $B3Pos[0] = 0
                           $B4Pos[0] = 0
                           ExitLoop
                        EndIf
                        Sleep(500)
                 EndIf
 
                 If $B4Pos[0] = 0 Then
                        $ClickCheck = MsgBox(6+65536, "Locate fourth barrack", "Click Continue then click on your fourth barrack. Cancel if not available", 0, $BotGUI)
                        If $ClickCheck = 11 Then
                           WinActivate ($HWnD)
                           FindPos($B4Pos)
                        ElseIf $ClickCheck = 10 Then
                           $B1Pos[0] = 0
                           $B2Pos[0] = 0
                           $B3Pos[0] = 0
                           $B4Pos[0] = 0
                           ExitLoop
                        EndIf
                        Sleep(500)
                 EndIf
                 ExitLoop(2)
          WEnd
   WEnd
EndFunc
 
Func TrainBarrack($x, $y, $z)
   ControlClick ($HWnD, "","", "left", "1", $x, $y)
   Sleep(1000)
   ControlClick ($HWnD, "","", "left", "1", 560*$x_ratio, 490*$y_ratio)
   Sleep(1000)
   Select
   Case $z = "Barbarian"
          For $i = 1 To 65 Step 1
                 ControlClick ($HWnD, "","", "left", "1", 220*$x_ratio, 270*$y_ratio)
                 Sleep(50)
          Next
   Case $z = "Archer"
          For $i = 1 To 65 Step 1
                 ControlClick ($HWnD, "","", "left", "1", 310*$x_ratio, 270*$y_ratio)
                 Sleep(50)
          Next
   Case $z = "Goblin"
          For $i = 1 To 65 Step 1
                 ControlClick ($HWnD, "","", "left", "1", 490*$x_ratio, 270*$y_ratio)
                 Sleep(50)
          Next
   Case $z = "Giant"
          For $i = 1 To 15 Step 1
                 ControlClick ($HWnD, "","", "left", "1", 400*$x_ratio, 270*$y_ratio)
                 Sleep(50)
          Next
   EndSelect
   Sleep(1000)
   ControlClick ($HWnD, "","", "left", "1", 656*$x_ratio, 113*$y_ratio)
   Sleep(1000)
EndFunc
 
Func Train()
   If $B1Pos[0] <> 0 Then
          TrainBarrack($B1Pos[0],$B1Pos[1],$B1Troop)
   EndIf
   If $B2Pos[0] <> 0 Then
          TrainBarrack($B2Pos[0],$B2Pos[1],$B2Troop)
   EndIf
   If $B3Pos[0] <> 0 Then
          TrainBarrack($B3Pos[0],$B3Pos[1],$B3Troop)
   EndIf
   If $B4Pos[0] <> 0 Then
          TrainBarrack($B4Pos[0],$B4Pos[1],$B4Troop)
   EndIf
EndFunc
 
#EndRegion ##### TRAIN #####
 
#Region ##### ATTACK #####
Func PrepareAttack()
   ;TrayTip ("Attack mode started!","Minimum Gold: " & $MinGold & ". Minimum Elixir: " & $MinElixir & ". Search Mode: " & $SearchMode, 0, $TIP_ICONASTERISK)
   ControlClick ($HWnD, "","", "left", "1", 50*$x_ratio, 500*$y_ratio) ;Click Attack
   Sleep(2000)
   ControlClick ($HWnD, "","", "left", "1", 190*$x_ratio, 420*$y_ratio) ;Click Find a Match
   Sleep(2000)
   ControlClick ($HWnD, "","", "left", "1", 470*$x_ratio, 330*$y_ratio) ;Click Break Shield
EndFunc
 
Func CheckScreen()
   Local $Check = ""
   $i = 0
   While $Check = "" And $ErrorCheck = 0
          $Check = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left*$x_ratio,$Top*$y_ratio,$Right*$x_ratio,$Bottom*$y_ratio,0)
          $Check = StringStripWS($Check, 8)
          Sleep(200)
          $i += 1
          If $i > 150 Then
                 $ErrorCheck = 1
                 Exit
          EndIf
   WEnd
EndFunc
 
Func VillageSearch()
   CheckScreen()
   ReadValue()
   CompareValue()
   While $SearchCheck = 0 And $ErrorCheck = 0
          ControlClick ($HWnD, "","", "left", "1", 715*$x_ratio, 405*$y_ratio) ;Click Next
          CheckScreen()
          ReadValue()
          CompareValue()
   WEnd
   If $ErrorCheck = 1 Then
          Restart()
          Attack()
   Else
          TrayTip ("Enemy Found!","Requirement met:  Gold: " & $Gold & ". Elixir: " & $Elixir, 0, $TIP_ICONASTERISK)
          Sleep(20000)
   EndIf
EndFunc
 
Func CheckTroop($a)
   If $B1Troop = $a Or $B2Troop = $a Or $B3Troop = $a Or $B4Troop = $a Then
          Return True
   Else
          Return False
   EndIf
EndFunc
 
Func AssignTroop()
   If CheckTroop("Barbarian") Then
          $Barbarian[0] = $Troop[0][0]
          #Barbarian[1] = $Troop[0][1]
          If CheckTroop("Archer") Then
                 $Archer[0] = $Troop[1][0]
                 $Archer[1] = $Troop[1][1]
                 If CheckTroop("Goblin") Then
                        $Goblin[0] = $Troop[2][0]
                        $Goblin[1] = $Troop[2][1]
                        If CheckTroop("Giant") Then
                           $Giant[0] = $Troop[3][0]
                           $Giant[1] = $Troop[3][1]
                        EndIf
                 ElseIf CheckTroop("Giant") Then
                        $Giant[0] = $Troop[2][0]
                        $Giant[1] = $Troop[2][1]
                 EndIf
          ElseIf CheckTroop("Goblin") Then
                 $Goblin[0] = $Troop[1][0]
                 $Goblin[1] = $Troop[1][1]
                 If CheckTroop("Giant") Then
                        $Giant[0] = $Troop[2][0]
                        $Giant[1] = $Troop[2][1]
                 EndIf
          ElseIf CheckTroop("Giant") Then
                 $Giant[0] = $Troop[1][0]
                 $Giant[1] = $Troop[1][1]
          EndIf
   ElseIf CheckTroop("Archer") Then
          $Archer[0] = $Troop[0][0]
          $Archer[1] = $Troop[0][1]
          If CheckTroop("Goblin") Then
                 $Goblin[0] = $Troop[1][0]
                 $Goblin[1] = $Troop[1][1]
                 If CheckTroop("Giant") Then
                        $Giant[0] = $Troop[2][0]
                        $Giant[1] = $Troop[2][1]
                 EndIf
          ElseIf CheckTroop("Giant") Then
                 $Giant[0] = $Troop[1][0]
                 $Giant[1] = $Troop[1][1]
          EndIf
   ElseIf CheckTroop("Goblin") Then
          $Goblin[0] = $Troop[0][0]
          $Goblin[1] = $Troop[0][1]
          If CheckTroop("Giant") Then
                 $Giant[0] = $Troop[1][0]
                 $Giant[1] = $Troop[1][1]
          EndIf
   ElseIf CheckTroop("Giant") Then
          $Giant[0] = $Troop[0][0]
          $Giant[1] = $Troop[0][1]
   EndIf
EndFunc
 
Func DropAll()
   ControlClick ($HWnD, "","", "left", "1", $Troop[2][0], $Troop[2][1])
   Sleep(500)
   For $i = 0 to 4 Step 1
          ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
          Sleep(100)
   Next
   Sleep(500)
   ControlClick ($HWnD, "","", "left", "1", $Troop[0][0], $Troop[0][1])
   Sleep(300)
   For $x = 0 to 15 Step 1
          For $i = 0 to 4 Step 1
                 ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
                 Sleep(100)
          Next
          Sleep(300)
   Next
   Sleep(500)
   ControlClick ($HWnD, "","", "left", "1", $Troop[1][0], $Troop[1][1])
   Sleep(300)
   For $x = 0 to 8 Step 1
          For $i = 0 to 4 Step 1
                 ControlClick ($HWnD, "","", "left", "1", $UpLeft[$i][0], $UpLeft[$i][1])
                 Sleep(100)
          Next
          Sleep(300)
   Next
   Sleep(500)
   ControlClick ($HWnD, "","", "left", "1", $Troop[2][0], $Troop[2][1])
   Sleep(500)
   For $i = 0 to 4 Step 1
          ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
          Sleep(100)
   Next
   Sleep(500)
   ControlClick ($HWnD, "","", "left", "1", $Troop[0][0], $Troop[0][1])
   Sleep(300)
   For $x = 0 to 15 Step 1
          For $i = 0 to 4 Step 1
                 ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
                 Sleep(100)
          Next
          Sleep(300)
   Next
   Sleep(500)
   ControlClick ($HWnD, "","", "left", "1", $Troop[1][0], $Troop[1][1])
   Sleep(300)
   For $x = 0 to 8 Step 1
          For $i = 0 to 4 Step 1
                 ControlClick ($HWnD, "","", "left", "1", $UpRight[$i][0], $UpRight[$i][1])
                 Sleep(100)
          Next
          Sleep(300)
   Next
   Sleep(500)
EndFunc
 
Func DropTroop()
   DropCombo($UpLeft)
   DropCombo($UpRight)
EndFunc
 
Func DropCombo($Wing)
   If CheckTroop("Giant") Then
          ControlClick ($HWnD, "","", "left", "1", $Giant[0], $Giant[1])
          Sleep(300)
          For $i = 1 to 3 Step 1
                 ControlClick ($HWnD, "","", "left", "1", $Wing[$i][0], $Wing[i][1])
                 Sleep(100)
          Next
          Sleep(300)
   EndIf
   If CheckTroop("Barbarian") Then
          ControlClick ($HWnD, "","", "left", "1", $Barbarian[0], $Barbarian[1])
          Sleep(300)
          For $x = 0 to 2 Step 1
                 For $i = 0 to 4 Step 1
                        ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
                        Sleep(100)
                 Next
          Next
          Sleep(300)
   EndIf
   If CheckTroop("Archer") Then
          ControlClick ($HWnD, "","", "left", "1", $Archer[0], $Archer[1])
          Sleep(300)
          For $x = 0 to 2 Step 1
                 For $i = 0 to 4 Step 1
                        ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
                        Sleep(100)
                 Next
          Next
          Sleep(300)
   EndIf
   If CheckTroop("Goblin") Then
          ControlClick ($HWnD, "","", "left", "1", $Goblin[0], $Goblin[1])
          Sleep(300)
          For $x = 0 to 2 Step 1
                 For $i = 0 to 4 Step 1
                        ControlClick ($HWnD, "","", "left", "1", , $Wing[$i][0], $Wing[i][1])
                        Sleep(100)
                 Next
          Next
          Sleep(30)
   EndIf
EndFunc
 
Func ReadValue()
   $Read = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left*$x_ratio,$Top*$y_ratio,$Right*$x_ratio,$Bottom*$y_ratio,0)      ;Capture screen region with gold and elixir
   ;MsgBox(0,"Read",$Read)
   $Read = StringRegExpReplace(StringRegExpReplace($Read, "(\v)+", @CRLF), "\A\v|\v\Z", "")
   ;MsgBox(0,"Read",$Read)
   $Read = StringSplit($Read, @CRLF, 1) ;Strip whitespaces & blank lines and split into array
   ;MsgBox(0,"Read",$Read[2] & @CR & $Read[3])
   $Gold = Number(StringRegExpReplace($Read[2], "[^[:digit:]]", ""))    ;Convert gold to number
   $Elixir = Number(StringRegExpReplace($Read[3], "[^[:digit:]]", ""))  ;Convert exlir to number
   ;$Dark = Number(StringStripWS($Read[4], $STR_STRIPALL))
   ;MsgBox(0,"Result", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Dark: " & $Dark)
   ;TrayTip ("Current Search","Gold: " & $Gold & ". Elixir: " & $Elixir, 0, $TIP_ICONASTERISK)
   ;SplashTextOn("Current Search","Gold: " & $Gold & @CR & "Elixir: " & $Elixir,200,70)
 
EndFunc
 
Func CompareValue()
   If $Gold >= $MinGold Then
          If $Elixir >= $MinElixir Then
                 ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Requirement met.")
                 Select
                        Case $SearchMode = 1
                           $SearchCheck = 1
                        Case $SearchMode = 2
                           $SearchCheck = 1
                        Case Else
                           $SearchCheck = 0
                 EndSelect
          Else
                 ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR &  "Not enough " & $MinElixir & " Elixir.")
                 Select
                        Case $SearchMode = 1
                           $SearchCheck = 1
                        Case $SearchMode = 2
                           $SearchCheck = 0
                        Case Else
                           $SearchCheck = 0
                 EndSelect
          EndIf
   Else
          If $Elixir >= $MinElixir Then
                 ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Not enough " & $MinGold & " Gold.")
                 Select
                        Case $SearchMode = 1
                           $SearchCheck = 1
                        Case $SearchMode = 2
                           $SearchCheck = 0
                        Case Else
                           $SearchCheck = 0
                 EndSelect
          Else
                 ;MsgBox(0, "Gold & Elixir Check", "Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & "Not enough " & $MinGold & " Gold and " & $MinElixir & " Elixir." )
                 Select
                        Case $SearchMode = 1
                           $SearchCheck = 0
                        Case $SearchMode = 2
                           $SearchCheck = 0
                        Case Else
                           $SearchCheck = 0
                 EndSelect
          EndIf
   EndIf
EndFunc
#EndRegion ##### ATTACK #####
 
Func Initiate()
   ControlClick ($HWnD, "","", "left", "1", 290, 150) ;Click BlueStacks
   Sleep(60000)
   ZoomOut()
   Sleep(10000)
EndFunc
 
Func ZoomOut()
   For $i = 1 To 20 Step 1
          ControlSend($HWnD, "", "", "{DOWN}", 0)
          Sleep(500)
   Next
EndFunc
 
Func Restart()
   ControlClick ($HWnD, "","", "left", "1", 125, 575)
   Sleep(2000)
   ControlClick ($HWnD, "","", "left", "1", 125, 577)
   Sleep(2000)
   ControlClick ($HWnD, "","", "left", "1", 205, 575)
   Sleep(2000)
   MouseClickDrag("left", 700, 300, 700, 120)
   Sleep(2000)
   ControlClick ($HWnD, "","", "left", "1", 290, 160)
   Sleep(50000)
EndFunc
 
Func Pause()
   $Paused = NOT $Paused
   While $Paused
          Sleep(100)
   TrayTip("Script Paused","Press Space to Unpause", 0, $TIP_ICONASTERISK)
   WEnd
EndFunc
 
Func Terminate()
   Exit
EndFunc

I made a small mistake, if you want to use the tesseract included change to #include "Tesseract.au3" in the code
If you want it to run continuously (not recommended), uncomment ;While1 and WEnd in Func Start(), also uncomment ;Sleep(900000) so it will wait for troops training

Dec 12, 2014#46

Can you guide how to use it 🙁. I have already istalled AutoIT and tesseract-ocr-setup-3.02.02. Thank you.

I run the Search Function.exe but nothing happend. The Bluestack windows always on top, can not exit Search Fuction windows. My bluestack res is 800x600

Dec 12, 2014#47

Since the program will put Bluestacks into the foreground for Tesseract to read, it's best you drag the program to one side where it won't be obstructed by BlueStacks. You have to zoom out all the way and click attack before you press Start. After you pressed Start the function will run until it find a match and you cannot stop it with button or close windows. Press Shift+ESC to force close the program. Can you try again and let me know how it goes?

Dec 12, 2014#48

Since the program will put Bluestacks into the foreground for Tesseract to read, it's best you drag the program to one side where it won't be obstructed by BlueStacks. You have to zoom out all the way and click attack before you press Start. After you pressed Start the function will run until it find a match and you cannot stop it with button or close windows. Press Shift+ESC to force close the program. Can you try again and let me know how it goes?

Thanks for your reply. I pressed "Start" button after click Attack. It's works (next) but only 1 time (next 1 time) and stop. I can't use Shift Esc to stop tool too. Need to End task on Task Manager 🙂
p/s my system is windows 8.1 64bit

Dec 12, 2014#49

qaqaq wrote:

Antidote wrote:

Since the program will put Bluestacks into the foreground for Tesseract to read, it's best you drag the program to one side where it won't be obstructed by BlueStacks. You have to zoom out all the way and click attack before you press Start. After you pressed Start the function will run until it find a match and you cannot stop it with button or close windows. Press Shift+ESC to force close the program. Can you try again and let me know how it goes?

Thanks for your reply. I pressed "Start" button after click Attack. It's works (next) but only 1 time (next 1 time) and stop. I can't use Shift Esc to stop tool too. Need to End task on Task Manager 🙂
p/s my system is windows 8.1 64bit

Hi @qaqaq,

  1. Placed the windows as shown in the screen capture.
  2. Set your requirement on the min gold and elixer. (Ignore the barrack dropdown menu)
  3. ZOOM out.. all the way.. til can't zoom out anymore.
  4. Click "Attack!", then click "Find a match".
  5. Click "Start on the antidote's Search function.
  6. Wah la, it will keep search til meet your requirement and display message in the task bar
Dec 12, 2014#50

Thanks odySSeys .
I did it. But still the same. Herre is vid 🙂

This discussion is closed.