Advertisement
Guest User

Tesseract Gold & Elixir

a guest
Dec 9th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.54 KB | None | 0 0
  1. #include <Tesseract.au3>
  2. #include <TrayConstants.au3>
  3.  
  4. Opt ("MouseClickDelay", 10)
  5. Opt ("MouseClickDownDelay", 10)
  6. Opt ("MouseCoordMode", 0)
  7.  
  8. $Title = "BlueStacks App Player"
  9. $Full = WinGetTitle ($Title)
  10. $HWnD = WinGetHandle ($Full)
  11. WinActivate ($HWnD)
  12.  
  13. Global $Left = 45
  14. Global $Top = 70
  15. Global $Right = 660
  16. Global $Bottom = 490
  17. Global $BSsize = WinGetClientSize($hWnd)
  18. Global $x_ratio = $BSsize[0]/800, $y_ratio = $BSsize[1]/600
  19.  
  20. Global $Gold, $Elixir
  21. Global $SearchTimeOut = False
  22.  
  23. HotKeySet ("{SPACE}", "Terminate")
  24.  
  25. Func ZoomOut()
  26.    For $i = 1 To 20 Step 1
  27.       ControlSend($HWnD, "", "", "{DOWN}", 0)
  28.       Sleep(500)
  29.    Next
  30. EndFunc
  31.  
  32. Func CheckScreen()
  33.    Local $Check = "", $i = 0
  34.    While $Check = "" And $SearchTimeOut = False
  35.       $Check = _TesseractWinCapture($HWnD,"",0,"",1,2,$Left*$x_ratio,$Top*$y_ratio,$Right*$x_ratio,$Bottom*$y_ratio,0)
  36.       $Check = StringStripWS($Check, 8)
  37.       Sleep(200)
  38.       $i += 1
  39.       If $i > 150 Then
  40.          $SearchTimeOut = True
  41.       EndIf
  42.    WEnd
  43. EndFunc
  44.  
  45. Func ReadValue()
  46.    $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
  47.    $Read = StringSplit(StringRegExpReplace(StringRegExpReplace($Read, "(\v)+", @CRLF), "\A\v|\v\Z", ""), @CRLF, 1)  ;Strip whitespaces & blank lines and split into array
  48.    $Gold = Number(StringRegExpReplace($Read[2], "[^[:digit:]]", ""))    ;Convert gold to number
  49.    $Elixir = Number(StringRegExpReplace($Read[3], "[^[:digit:]]", ""))  ;Convert exlir to number
  50.    SplashTextOn("Current Search","Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & @CR & "Press Space Bar to Stop",200,100)
  51. EndFunc
  52.  
  53. Func StartAttack()
  54.    ControlClick ($HWnD, "","", "left", "1", 50*$x_ratio, 500*$y_ratio)  ;Click Attack
  55.    Sleep(2000)
  56.    ControlClick ($HWnD, "","", "left", "1", 190*$x_ratio, 420*$y_ratio) ;Click Find a Match
  57.    Sleep(2000)
  58.    ControlClick ($HWnD, "","", "left", "1", 470*$x_ratio, 330*$y_ratio) ;Click Break Shield
  59. EndFunc
  60.  
  61. Func Terminate()
  62.    SplashTextOn("Tesseract Gold & Elixir Test","Exiting...",200,50)
  63.    CheckScreen()
  64.    ControlClick ($HWnD, "","", "left", "1", 70*$x_ratio, 433*$y_ratio) ;Click End Battle
  65.    Sleep(2000)
  66.    SplashOff()
  67.    Exit
  68. EndFunc
  69.  
  70. Func Test()
  71.    CheckScreen()
  72.    ReadValue()
  73.    Sleep(5000)
  74.    ControlClick ($HWnD, "","", "left", "1", 715*$x_ratio, 405*$y_ratio) ;Click Next
  75. EndFunc
  76.  
  77. SplashTextOn("Tesseract Gold & Elixir Test","Press Space Bar to Stop",200,50)
  78. Zoomout()
  79. StartAttack()
  80. While Not $SearchTimeOut
  81.    Test()
  82. WEnd
  83. Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement