Need help with bot

08/27/2015 20:13 Dosenhosenjoe#1
Hello,
i try to code a bot for Total War: Arena for around 4 days now nad i am almost done ^^ but i have a problem: I have a simple GUI but if i try to click on start it doesnt work. It says that a variable isnt declared but it is ... here is my code:
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Fabian\Desktop\Scripts\StartStop.kxf
$Form1 = GUICreate("Total War Arena Bot", 467, 181, -1, -1)
Global $start = GUICtrlCreateButton("Start", 64, 56, 139, 65)
Global $ende = GUICtrlCreateButton("Stop", 272, 56, 139, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		 Case $start
			start()

		 Case $ende
			ende()

	EndSwitch
WEnd

Global $pixel = PixelSearch(956, 916, 988, 939, 0x1A1B1C)
Global $pixel2 = PixelSearch(963, 170,971, 175, 0xFAE788)


Func ende()
   Exit
EndFunc


Func start()
While 1
If IsArray($pixel) = True Then
MouseClick("left", 959, 171 )
EndIf
Sleep (5000)
  Do
	  While 1
		 Sleep(100)
	  WEnd
   Until IsArray($pixel2) = True
Sleep(70000)
Send("{^a}")
Sleep(10000)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(34004)
MouseClick("left",961, 786)
Sleep(5000)
MouseClick("left", 1268, 843)
Sleep(5000)
MouseClick("left", 959, 627)
WEnd
EndFunc
It says that the variable pixel1 isn't declared but as you see it is ...
08/27/2015 20:51 WJNeeson#2
Quote:
Originally Posted by Dosenhosenjoe View Post
Hello,
i try to code a bot for Total War: Arena for around 4 days now nad i am almost done ^^ but i have a problem: I have a simple GUI but if i try to click on start it doesnt work. It says that a variable isnt declared but it is ... here is my code:
Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Fabian\Desktop\Scripts\StartStop.kxf
$Form1 = GUICreate("Total War Arena Bot", 467, 181, -1, -1)
Global $start = GUICtrlCreateButton("Start", 64, 56, 139, 65)
Global $ende = GUICtrlCreateButton("Stop", 272, 56, 139, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit

		 Case $start
			start()

		 Case $ende
			ende()

	EndSwitch
WEnd

Global $pixel = PixelSearch(956, 916, 988, 939, 0x1A1B1C)
Global $pixel2 = PixelSearch(963, 170,971, 175, 0xFAE788)


Func ende()
   Exit
EndFunc


Func start()
While 1
If IsArray($pixel) = True Then
MouseClick("left", 959, 171 )
EndIf
Sleep (5000)
  Do
	  While 1
		 Sleep(100)
	  WEnd
   Until IsArray($pixel2) = True
Sleep(70000)
Send("{^a}")
Sleep(10000)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(12500)
Send ("{l}")
Send ("{l}")
Send ("{l}")
Send ("{l}")
Sleep(34004)
MouseClick("left",961, 786)
Sleep(5000)
MouseClick("left", 1268, 843)
Sleep(5000)
MouseClick("left", 959, 627)
WEnd
EndFunc
It says that the variable pixel1 isn't declared but as you see it is ...
When you start the script the gui will be created and you go into your loop "While 1"
PHP Code:
While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

         Case 
$start
            start
()

         Case 
$ende
            ende
()

    EndSwitch
WEnd 
you dont get out of that loop, until you press start to jump to your function

PHP Code:
Loop

Defines

Function 
so when you press start you skip over your defines and both variables cannot be found, couse they dont exist :P

you just have to put the defines into your function like this

PHP Code:
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Fabian\Desktop\Scripts\StartStop.kxf
$Form1 GUICreate("Total War Arena Bot"467181, -1, -1)
Global 
$start GUICtrlCreateButton("Start"645613965)
Global 
$ende GUICtrlCreateButton("Stop"2725613965)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

         Case 
$start
            start
()

         Case 
$ende
            ende
()

    EndSwitch
WEnd



Func ende
()
   Exit
EndFunc


Func start
()
    
Local $pixel PixelSearch(9569169889390x1A1B1C)
    
Local $pixel2 PixelSearch(963170,9711750xFAE788)
    While 
1
        
If IsArray($pixel) = True Then
            MouseClick
("left"959171 )
        EndIf
        
Sleep (5000)
        Do
            While 
1
                Sleep
(100)
            
WEnd
        Until IsArray
($pixel2) = True
        Sleep
(70000)
        
Send("{^a}")
        
Sleep(10000)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(12500)
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Send ("{l}")
        
Sleep(34004)
        
MouseClick("left",961786)
        
Sleep(5000)
        
MouseClick("left"1268843)
        
Sleep(5000)
        
MouseClick("left"959627)
    
WEnd
EndFunc 
08/27/2015 21:09 Dosenhosenjoe#3
Vielen Dank! ist mein erster code überhaupt ^^