Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Tesseract.au3>
- #include <TrayConstants.au3>
- Opt ("MouseClickDelay", 10)
- Opt ("MouseClickDownDelay", 10)
- Opt ("MouseCoordMode", 0)
- $Title = "BlueStacks App Player"
- $Full = WinGetTitle ($Title)
- $HWnD = WinGetHandle ($Full)
- WinActivate ($HWnD)
- Global $Left = 45
- Global $Top = 70
- Global $Right = 660
- Global $Bottom = 490
- Global $BSsize = WinGetClientSize($hWnd)
- Global $x_ratio = $BSsize[0]/800, $y_ratio = $BSsize[1]/600
- Global $Gold, $Elixir
- Global $SearchTimeOut = False
- HotKeySet ("{SPACE}", "Terminate")
- Func ZoomOut()
- For $i = 1 To 20 Step 1
- ControlSend($HWnD, "", "", "{DOWN}", 0)
- Sleep(500)
- Next
- EndFunc
- Func CheckScreen()
- Local $Check = "", $i = 0
- While $Check = "" And $SearchTimeOut = False
- $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
- $SearchTimeOut = True
- EndIf
- WEnd
- 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
- $Read = StringSplit(StringRegExpReplace(StringRegExpReplace($Read, "(\v)+", @CRLF), "\A\v|\v\Z", ""), @CRLF, 1) ;Strip whitespaces & blank lines and split into array
- $Gold = Number(StringRegExpReplace($Read[2], "[^[:digit:]]", "")) ;Convert gold to number
- $Elixir = Number(StringRegExpReplace($Read[3], "[^[:digit:]]", "")) ;Convert exlir to number
- SplashTextOn("Current Search","Gold: " & $Gold & @CR & "Elixir: " & $Elixir & @CR & @CR & "Press Space Bar to Stop",200,100)
- EndFunc
- Func StartAttack()
- 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 Terminate()
- SplashTextOn("Tesseract Gold & Elixir Test","Exiting...",200,50)
- CheckScreen()
- ControlClick ($HWnD, "","", "left", "1", 70*$x_ratio, 433*$y_ratio) ;Click End Battle
- Sleep(2000)
- SplashOff()
- Exit
- EndFunc
- Func Test()
- CheckScreen()
- ReadValue()
- Sleep(5000)
- ControlClick ($HWnD, "","", "left", "1", 715*$x_ratio, 405*$y_ratio) ;Click Next
- EndFunc
- SplashTextOn("Tesseract Gold & Elixir Test","Press Space Bar to Stop",200,50)
- Zoomout()
- StartAttack()
- While Not $SearchTimeOut
- Test()
- WEnd
- Exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement