[AutoIt] Need some help.

02/02/2013 13:12 Maffiagang#1
Hello fellow Epvpers!

I am trying to make myself a buff program with the help of [Only registered and activated users can see links. Click Here To Register...] 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:

[Only registered and activated users can see links. Click Here To Register...]

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:


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 omer36#2
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] = timer()
;
$task[x][1] = checkbox()
;
$task[x][2] = inputbox()
;
$keys[x]    = your keys

$gui 
GUICreate(''12020*UBound($task)+10, Default, Default, 0x10C800008)
For 
$i=0 To UBound($task)-1
    $task
[$i][1]=GUICtrlCreateCheckbox('F'&$i+1105+$i*203520)
    
$task[$i][2]=GUICtrlCreateInput(1000555+$i*2050201)
Next
;^gui create relative to x


While GUIGetMsg()<>-;-$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 Maffiagang#3
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


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 lolkop#4
Quote:
Originally Posted by Maffiagang View Post
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>
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.