|
You last visited: Today at 21:04
Advertisement
[AutoIt] Need some help.
Discussion on [AutoIt] Need some help. within the AutoIt forum part of the Coders Den category.
02/02/2013, 13:12
|
#1
|
elite*gold: 0
Join Date: Jun 2008
Posts: 319
Received Thanks: 496
|
[AutoIt] Need some help.
Hello fellow Epvpers!
I am trying to make myself a buff program with the help of  wrote a few years ago.
Now i need some extra help, because i dont want my program to have 1 key option but 9!!
This is how my current GUI looks like:
and those are also the options i want to use. (F1-F9 and a user set interval)
This is my code for handling the Keys and intervals:
While 1
$msg = GUIGetMsg()
Select
Case $msg = $startbutton1
$timer1 = TimerInit()
$Time1 = GUICtrlRead($Time1)
While 1
$timed1 = TimerDiff($timer1)
If $timed1 > $Time1 Then
ControlSend("Insanity FlyFF", "", "", "{F1}")
$timer1 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton2
$timer2 = TimerInit()
$Time2 = GUICtrlRead($Time2)
While 1
$timed2 = TimerDiff($timer2)
If $timed2 > $Time2 Then
ControlSend("Insanity FlyFF", "", "", "{F2}")
$timer2 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton3
$timer3 = TimerInit()
$Time3 = GUICtrlRead($Time3)
While 1
$timed3 = TimerDiff($timer3)
If $timed3 > $Time3 Then
ControlSend("Insanity FlyFF", "", "", "{F3}")
$timer3 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton4
$timer4 = TimerInit()
$Time4 = GUICtrlRead($Time4)
While 1
$timed4 = TimerDiff($timer4)
If $timed4 > $Time4 Then
ControlSend("Insanity FlyFF", "", "", "{F4}")
$timer4 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton5
$timer5 = TimerInit()
$Time5 = GUICtrlRead($Time5)
While 1
$timed5 = TimerDiff($timer5)
If $timed5 > $Time5 Then
ControlSend("Insanity FlyFF", "", "", "{F5}")
$timer5 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton6
$timer6 = TimerInit()
$Time6 = GUICtrlRead($Time6)
While 1
$timed6 = TimerDiff($timer6)
If $timed6 > $Time6 Then
ControlSend("Insanity FlyFF", "", "", "{F6}")
$timer6 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton7
$timer7 = TimerInit()
$Time7 = GUICtrlRead($Time7)
While 1
$timed7 = TimerDiff($timer7)
If $timed7 > $Time7 Then
ControlSend("Insanity FlyFF", "", "", "{F7}")
$timer7 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton8
$timer8 = TimerInit()
$Time8 = GUICtrlRead($Time8)
While 1
$timed8 = TimerDiff($timer8)
If $timed8 > $Time8 Then
ControlSend("Insanity FlyFF", "", "", "{F8}")
$timer8 = TimerInit()
EndIf
WEnd
Case $msg = $startbutton9
$timer9 = TimerInit()
$Time9 = GUICtrlRead($Time9)
While 1
$timed9 = TimerDiff($timer9)
If $timed9 > $Time9 Then
ControlSend("Insanity FlyFF", "", "", "{F9}")
$timer9 = TimerInit()
EndIf
WEnd
Case $msg = $GUI_EVENT_CLOSE
GUIDelete()
ExitLoop
EndSelect
WEnd
Now i dont know why, (probably because i dont have much knowledge of coding in autoit or any other langue/program for that matter) But for some reason only my first option (F1) works and then ONLY IF MY MOUSE IS HEAVILY ACTIVE...
As you all can hear from what i have said... i need help.
I am hoping someone can EXPLAIN ( NOT give me the code) what i am doing wrong, and if this is even possible with AutoIt. (read something about multi threading not being possible with AutoIt... Should i go over to VB for this?)
I am looking forward to all your reactions.
Thanks in advance,
Maffiagang
|
|
|
02/02/2013, 22:15
|
#2
|
elite*gold: 0
Join Date: Mar 2009
Posts: 2,317
Received Thanks: 1,255
|
u have too many loops..
if its possible (it should be) use only 1 infinite loop.
can you handel with arrays?
my english isnt verry well, so i try to explain with some comments
(this script was made by a epvp member (i think it was lolkop), just modified it)
PHP Code:
Dim $task[9][3], $keys[9] = ["{F1}","{F2}","{F3}","{F4}","{F5}","{F6}","{F7}","{F8}","{F9}"] ;$task[x][0] = x * timer() ;$task[x][1] = x * checkbox() ;$task[x][2] = x * inputbox() ;$keys[x] = your keys
$gui = GUICreate('', 120, 20*UBound($task)+10, Default, Default, 0x10C80000, 8) For $i=0 To UBound($task)-1 $task[$i][1]=GUICtrlCreateCheckbox('F'&$i+1, 10, 5+$i*20, 35, 20) $task[$i][2]=GUICtrlCreateInput(1000, 55, 5+$i*20, 50, 20, 1) Next ;^gui create relative to x
While GUIGetMsg()<>-3 ;-3 = $GUI_EVENT_CLOSE For $i=0 To UBound($task)-1 If BitAND(GUICtrlRead($task[$i][1]),1) And TimerDiff($task[$i][0])>=GUICtrlRead($task[$i][2]) Then ControlSend("Insanity FlyFF", "", "", $keys[$i]) $task[$i][0]=TimerInit() ;check for your 1st $checkbox (array [0]), if its checked ;and the 1st $timer is bigger then the 1st inputbox ;it sends the 1st $key ;reset the $timer ;now the 2nd... (1-9) EndIf Next WEnd
|
|
|
02/02/2013, 23:19
|
#3
|
elite*gold: 0
Join Date: Jun 2008
Posts: 319
Received Thanks: 496
|
Thank you omer36 for your input, i am really not that well known yet with all that autoit offers. And what u send is confusing me. lol
While 1
$MSG = GUIGetMsg()
Select
Case $MSG = $STARTBUTTON
$TIMER1 = TimerInit()
$TIMER2 = TimerInit()
$TIMER3 = TimerInit()
$TIMER4 = TimerInit()
$TIMER5 = TimerInit()
$TIMER6 = TimerInit()
$TIMER7 = TimerInit()
$TIMER8 = TimerInit()
$TIMER9 = TimerInit()
$TIME1 = GUICtrlRead($TIME1)
$TIME2 = GUICtrlRead($TIME2)
$TIME3 = GUICtrlRead($TIME3)
$TIME4 = GUICtrlRead($TIME4)
$TIME5 = GUICtrlRead($TIME5)
$TIME6 = GUICtrlRead($TIME6)
$TIME7 = GUICtrlRead($TIME7)
$TIME8 = GUICtrlRead($TIME8)
$TIME9 = GUICtrlRead($TIME9)
While 1
$TIMED1 = TimerDiff($TIMER1)
$TIMED2 = TimerDiff($TIMER2)
$TIMED3 = TimerDiff($TIMER3)
$TIMED4 = TimerDiff($TIMER4)
$TIMED5 = TimerDiff($TIMER5)
$TIMED6 = TimerDiff($TIMER6)
$TIMED7 = TimerDiff($TIMER7)
$TIMED8 = TimerDiff($TIMER8)
$TIMED9 = TimerDiff($TIMER9)
If $TIMED1 > $TIME1 Then
ControlSend("Insanity FlyFF", "", "", "{F1}")
$TIMER1 = TimerInit()
ElseIf $TIMED2 > $TIME2 Then
ControlSend("Insanity FlyFF", "", "", "{F2}")
$TIMER2 = TimerInit()
ElseIf $TIMED3 > $TIME3 Then
ControlSend("Insanity FlyFF", "", "", "{F3}")
$TIMER3 = TimerInit()
ElseIf $TIMED4 > $TIME4 Then
ControlSend("Insanity FlyFF", "", "", "{F4}")
$TIMER4 = TimerInit()
ElseIf $TIMED5 > $TIME5 Then
ControlSend("Insanity FlyFF", "", "", "{F5}")
$TIMER5 = TimerInit()
ElseIf $TIMED6 > $TIME6 Then
ControlSend("Insanity FlyFF", "", "", "{F6}")
$TIMER6 = TimerInit()
ElseIf $TIMED7 > $TIME7 Then
ControlSend("Insanity FlyFF", "", "", "{F7}")
$TIMER7 = TimerInit()
ElseIf $TIMED8 > $TIME8 Then
ControlSend("Insanity FlyFF", "", "", "{F8}")
$TIMER8 = TimerInit()
ElseIf $TIMED9 > $TIME9 Then
ControlSend("Insanity FlyFF", "", "", "{F9}")
$TIMER9 = TimerInit()
EndIf
WEnd
Case $MSG = $STOPBUTTON
ExitLoop()
Case $MSG = $GUI_EVENT_CLOSE
GUIDelete()
EndSelect
WEnd
So i have fiddled around some myself, and reworked my script. The script above DID work with my GUI only just not without me keeping my mouse active (wut?), but it only works if you enter an interval for ALL 9 options... entering 0 doesnt work, neither does "".
Also for some reason ExitLoop does not work and without exiting the loop i cant close the program properly.
Some help on what i am doing wrong would me much appreciated, i know this what i made has to work, i probably am missing something...
|
|
|
02/03/2013, 11:53
|
#4
|
elite*gold: 280
Join Date: May 2007
Posts: 2,818
Received Thanks: 3,483
|
Quote:
Originally Posted by Maffiagang
Code:
While 1
[...]
<outer-loop actions>
While 1
[...]
<inner-loop actions>
WEnd
<outer-loop actions>
[...]
WEnd
|
to make you understand this a bit better, i've quoted your code, and simplyfied it a bit.
the problem with your script is, that u're using an never ending inner-loop. you should allready know, that scripting languages are executing your code line by line...
Code:
1: While <expression>
2: <action1>
3: WEnd
4: <action2>
[NOTE] <expression> can only be false, or true. Autoit is also able to convert any string/number to one of those two states, using a simple rule...
0 == False, everything else is True
which basicly means 1 = True, 2 = True, "blubb" = True, "" = True, 1337 = True, 0 = False....
a code like the one posted above will be executed like this:
Code:
1: If <expression> = True GoTo 2 Else GoTo 4
2: Execute <action1>
3: GoTo 1
4: Execute <action2>
this basicly means, if you use a static value like "1" as expression, expression can never be False, and there's no way out of that loop.
now if you use something like:
Code:
While <expression1>
While <expression2>
<action1>
Wend
<action2>
WEnd
with <expression1> = <expression2> = True, it will keep on performing <action1> but never reach <action2>
to get around this, you could simply put both actions into one loop like this:
Code:
While <expression1>
If <expression2> Then
<action1>
EndIf
<action2>
WEnd
This code will keep the function of the outer loop alive, while the innerloop will be executed within the outerloop, without killing the functionality of the outerloop.
|
|
|
All times are GMT +1. The time now is 21:04.
|
|