|
You last visited: Today at 14:30
Advertisement
Problem with autoit script
Discussion on Problem with autoit script within the AutoIt forum part of the Coders Den category.
01/31/2014, 14:37
|
#1
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
Problem with autoit script
Hi all im new on this forum.
First of all i got problem with this script, im making a bot for 1 game and bot will must do multi-tasks but i read that this can be done in autoit. My problem is when i want to use multiple tasks script become crazy 
I made few files, main (main bot and gui), buff(for buffing), cam(camera rotation), pick(for pick items), and now i need to put all that to work together without problems.
here is piece of code that i have problem with
Code:
; main function for start boting when pressed F9
Func _toggleStart()
; if process exists then start
If $proc = True Then
$run = Not $run ; pause script
; main loop
While $run
_checkMob()
If GUICtrlRead($cameraRoation) = $GUI_CHECKED Then
#include <cam.au3>
EndIf
If GUICtrlRead($pickItems) = $GUI_CHECKED Then
#include <pick.au3>
EndIf
#include <buffs.au3>
WEnd
EndIf
EndFunc
Func _checkMob()
$mob = PixelSearch(415, 44, 596, 54, 0xF84B49)
If IsArray($mob) And Not @error Then
ControlSend($win, "", "", "{3}")
Sleep(200)
Else
ControlSend($win, "", "", "{TAB}")
Sleep(200)
EndIf
EndFunc
and here is buff script
Code:
Global $win, $Input1, $Input2, $Input3, $Input4, $Input21, $Input22, $Input23, $Input24
Sleep(2000)
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{3}", 0)
Sleep(GUICtrlRead($Input1))
ControlSend($win, "", "", "{4}", 0)
Sleep(GUICtrlRead($Input2))
ControlSend($win, "", "", "{5}", 0)
Sleep(GUICtrlRead($Input3))
ControlSend($win, "", "", "{6}", 0)
Sleep(GUICtrlRead($Input4))
Send("{SHIFTUP}")
Sleep(100)
$Input1 = TimerInit()
$Input2 = TimerInit()
$Input3 = TimerInit()
$Input4 = TimerInit()
If TimerDiff($Input1) > GUICtrlRead($Input21) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{3}", 0)
Sleep(GUICtrlRead($Input1))
Send("{SHIFTUP}")
Sleep(100)
$Input1 = TimerInit()
EndIf
If TimerDiff($Input2) > GUICtrlRead($Input22) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{4}", 0)
Sleep(GUICtrlRead($Input2))
Send("{SHIFTUP}")
Sleep(100)
$Input2 = TimerInit()
EndIf
If TimerDiff($Input3) > GUICtrlRead($Input23) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{5}", 0)
Sleep(GUICtrlRead($Input3))
Send("{SHIFTUP}")
Sleep(100)
$Input3 = TimerInit()
EndIf
If TimerDiff($Input4) > GUICtrlRead($Input24) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{6}", 0)
Sleep(GUICtrlRead($Input4))
Send("{SHIFTUP}")
Sleep(100)
$Input4 = TimerInit()
EndIf
So problem is next, when i press F9 it start to aim and kill mobs, cam rotation works fine but it buff all time, and what i need is when i press F9 script start, buff once, start attack, pause attack when buff are ready too use again, use buff, start attack again. If you dont understand something like this,
F9 = bot start
1. buff (when done)
2. attack
3. when buff ready again (pause attack)
4. buff again
5. start attack
|
|
|
01/31/2014, 14:48
|
#2
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
You could try to CreateThreads but that's unstable because it's crashing a lot.
In AutoIt multiprocessing is one of the ways to get an application "multithreaded" but it's not as nice as for example in C#.
|
|
|
01/31/2014, 14:51
|
#3
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
I have trie to made something in c# and c++ looks so complicated, this is much more easier but as i see isnt so good
|
|
|
02/01/2014, 04:25
|
#4
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Try initializing the timer init outside the while loop.
Like this:
Code:
$Input1 = TimerInit()
While 1
If (TimerDiff($Input1) > 3000) Then
MsgBox(0,"buffTime","Sending keyStrokes")
$Input1 = TimerInit()
EndIf
$dif = TimerDiff($Input1)
ToolTip($dif,0,0)
WEnd
|
|
|
02/01/2014, 09:12
|
#5
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
You can use ControlSend in AutoItX.dll do use that in C#. It's not that hard.
|
|
|
02/01/2014, 15:47
|
#6
|
elite*gold: 0
Join Date: Jan 2014
Posts: 43
Received Thanks: 1
|
Quote:
Originally Posted by elmarcia
Try initializing the timer init outside the while loop.
Like this:
Code:
$Input1 = TimerInit()
While 1
If (TimerDiff($Input1) > 3000) Then
MsgBox(0,"buffTime","Sending keyStrokes")
$Input1 = TimerInit()
EndIf
$dif = TimerDiff($Input1)
ToolTip($dif,0,0)
WEnd
|
This still dont works now it switch bar every few seconds like before  , but problem isnt in buff script it works fine when i run it alone
buff.au3 it buff char, wait for timer to run out and buff again no problems
like this
Code:
Global $win, $Input1, $Input2, $Input3, $Input4, $Input21, $Input22, $Input23, $Input24
While 1
Sleep(2000)
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{3}", 0)
Sleep(GUICtrlRead($Input1))
ControlSend($win, "", "", "{4}", 0)
Sleep(GUICtrlRead($Input2))
ControlSend($win, "", "", "{5}", 0)
Sleep(GUICtrlRead($Input3))
ControlSend($win, "", "", "{6}", 0)
Sleep(GUICtrlRead($Input4))
Send("{SHIFTUP}")
Sleep(100)
$Input1 = TimerInit()
$Input2 = TimerInit()
$Input3 = TimerInit()
$Input4 = TimerInit()
If TimerDiff($Input1) > GUICtrlRead($Input21) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{3}", 0)
Sleep(GUICtrlRead($Input1))
Send("{SHIFTUP}")
Sleep(100)
$Input1 = TimerInit()
EndIf
If TimerDiff($Input2) > GUICtrlRead($Input22) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{4}", 0)
Sleep(GUICtrlRead($Input2))
Send("{SHIFTUP}")
Sleep(100)
$Input2 = TimerInit()
EndIf
If TimerDiff($Input3) > GUICtrlRead($Input23) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{5}", 0)
Sleep(GUICtrlRead($Input3))
Send("{SHIFTUP}")
Sleep(100)
$Input3 = TimerInit()
EndIf
If TimerDiff($Input4) > GUICtrlRead($Input24) Then
Send("{SHIFTDOWN}")
Sleep(100)
ControlSend($win, "", "", "{6}", 0)
Sleep(GUICtrlRead($Input4))
Send("{SHIFTUP}")
Sleep(100)
$Input4 = TimerInit()
EndIf
WEnd
only problem is when it need to do it while attack
|
|
|
07/20/2017, 01:51
|
#7
|
elite*gold: 0
Join Date: Nov 2009
Posts: 105
Received Thanks: 8
|
No clue if the owner still use the site or not, but a bit advise:
U have to manage ur code better, cause this is messy.
U should store the input valuses in variable, instead of pulling them every time from the GUI. If u did it cause u wana change the values anytime u want while the script running, then u can still do it easy on this way. It will be pretty much the same, but it help u make ur code become shorter and easyer to read and understand, when u have only this:
$delay1 = guictrlread($input1)
Sleep($delay1)
instead of this:
Sleep(GUICtrlRead($Input1))
U will realise the different when u write a long row.
Other thing, do not put the "include" stuff in an infinit loop or in any loop. Those stuffs have to called once, not every single milisecond.
The reason why it is not realy work, from first look is, cause u put ur buffing stuff in an infinite loop and every time reseting the timer when the loop get reseted in every few second. Every few second cause u put some sleep at the end of the while loop.
Still the main problem is the organisation, what the script do and when it is doing that. Placeing the stuffs on wrong place, make bugs or errors.
If u realy want multitask, better to use C, C#, or C++
But there is a function in AutoIt to run 2 different function next to each other at "same" time. Actualy not running at same time. While 1 running the other one is paused. What mean, the code is switching between the 2 function pretty fast.
Before u start codeing, better to write down what u want to make, and even make a diagram for it, just to be clear and see clear how it will work.
P.S.:
Sry for necro post, but maybe it will help for other ppls when they read it in a future, to do not fall into the same mistake.
|
|
|
07/20/2017, 17:56
|
#8
|
elite*gold: 4
Join Date: Aug 2011
Posts: 157
Received Thanks: 24
|
please dont push old threads ... this is from 2014 he can be a autoit pro now or learned c#
|
|
|
07/24/2017, 12:26
|
#9
|
elite*gold: 2
Join Date: Jul 2009
Posts: 14,456
Received Thanks: 4,685
|
#closed
las post 01.02.2014, 15:47
|
|
|
 |
Similar Threads
|
AutoIT Problem(e) mit meinem Bot Script
09/13/2013 - AutoIt - 6 Replies
Howdy,
Ich fange an AutoIT mit learning by doing zu lernen. Da ich schon immer über einen Farmbot für ein MMORPG nachdenke und niemand sowas releast hat, will ich ihn selbst schreiben, da er auch recht simpel aufgebaut sein soll.
Dieser in Zukunft 1. Bot von mir, soll zuerst mit einem Mausklick zu einer Monster-Route laufen, diese Monster töten, deren Gegenstände einsammeln, sich hinsetzen und regenerieren und dann das ganze von vorn.
Problem hierbei, das ich einfach nicht weiß, wie...
|
Erstes kleines Script in AutoIT (Problem)
03/04/2012 - AutoIt - 6 Replies
Hi Leute hab mir vor 5 Min AutoIt Runtergeladen und wollte mein erstes Kleines Script erstellen:
Einen Metin2 Autoschläger ^^
Run("metin2client.bin")
Sleep(7000)
Send("{Enter}NAME")
Sleep (1000)
Send ("{Enter}")
Sleep(1000)
|
Einfaches AutoIT Script Problem
08/24/2011 - General Coding - 6 Replies
Hey leute ;D
Habe ein Problem gerade bei meinem Script . Es soll automatisch okay nicht so automatisch xD eine Email erstellen . Ich komme nicht bei dem Email namen weiter . Hier das Video das ich hochgeladen habe für euch :
http://www.youtube.com/watch?v=eRiEzN8xjEk
Mfg
Die verarbeitung kan noch laufen deswegen kan das Video noch nicht klappen da ich alles schnell in 5 Minuten gamcht habe ich meine Soein Bot ist garnichts :P
Edit : Das Passwort wiederholen Problem hab ich jetz...
|
[HELP] Problem bei autoit script
10/24/2010 - AutoIt - 8 Replies
Hey habn problem mim autoit script .. des startet die programme nich und die coords beim mouseclick machts i-wo oben links obwohl xampp unten rechts ist ^^
run ("C:\Dokumente und Einstellungen\***\Desktop\Portmap\Portmap.exe" ;)
sleep ( 1000 )
run ("C:\Dokumente und Einstellungen\***\Desktop\XAMPP Control Panel.exe")
MouseClick ( "left" ])
sleep ( 1000 )
MouseClick
sleep ( 1000 )
run ("C:\Dokumente und Einstellungen\Dackupix3\Desktop\Pserver\Serverstar ter.vmc")
|
All times are GMT +1. The time now is 14:31.
|
|