Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 19:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Need help with bot

Discussion on Need help with bot within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2012
Posts: 5
Received Thanks: 0
Need help with bot

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 ...
Dosenhosenjoe is offline  
Old 08/27/2015, 20:51   #2
 
WJNeeson's Avatar
 
elite*gold: 1445
Join Date: Sep 2011
Posts: 199
Received Thanks: 177
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 
WJNeeson is offline  
Thanks
1 User
Old 08/27/2015, 21:09   #3
 
elite*gold: 0
Join Date: May 2012
Posts: 5
Received Thanks: 0
Vielen Dank! ist mein erster code überhaupt ^^
Dosenhosenjoe is offline  
Reply




All times are GMT +1. The time now is 19:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.