|
You last visited: Today at 19:18
Advertisement
Need help with bot
Discussion on Need help with bot within the AutoIt forum part of the Coders Den category.
08/27/2015, 20:13
|
#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 ...
|
|
|
08/27/2015, 20:51
|
#2
|
elite*gold: 1445
Join Date: Sep 2011
Posts: 199
Received Thanks: 177
|
Quote:
Originally Posted by Dosenhosenjoe
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", 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
Func ende()
Exit
EndFunc
Func start()
Local $pixel = PixelSearch(956, 916, 988, 939, 0x1A1B1C)
Local $pixel2 = PixelSearch(963, 170,971, 175, 0xFAE788)
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
|
|
|
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 ^^
|
|
|
All times are GMT +1. The time now is 19:18.
|
|