Jump to content

Help with some while's


eXXe
 Share

Recommended Posts

Hello Forum,

Im using since some days autoit v3 and try to make an good programm for me but :

I need 2 whiles workign at the same time, but how?

My code where i need it :

$count1 = 0
$count2 = 0
$count3 = 0
$count4 = 0
$count5 = 0

HotKeySet( "{F4}" , "_Train") 
Func _Train()   
    While 1
        If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then 
            While 2
                $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
            WEnd
        EndIf
        If $count1 = (GUICtrlRead($Down1)) Then 
    ;do something
        EndIf
        If $count2 = (GUICtrlRead($Down2)) Then 
    ;do something
        EndIf

        If $count3 = (GUICtrlRead($Down3)) Then 
    ;do something
        EndIf
;and much more
WEnd
EndFunc

It shall do a countup till the down input, if the count is the same like the input, it shall do another thing.

and all that with 6 things on one time.

The countup doesn't have to be in the funtion.

But it must run up +1 each second, and the other code must workign at the same time.

Maybe my english is a bit bad, and i cant explain good, but please try to help me ;)

If you didn't understood, just ask me ;)

Ps. I used the documenation and the search function and google already :D

Edited by eXXe
Link to comment
Share on other sites

I don't understand what you're trying to do exactly. If you use this code-

$count1 = 0
$count2 = 0
$count3 = 0
$count4 = 0
$count5 = 0

HotKeySet( "{F4}" , "_Train") 
Func _Train()    
    While 1
        If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then 
            $count1 = $count1 + 1  
            $count2 = $count2 + 1  
            $count3 = $count3 + 1  
            $count4 = $count4 + 1  
            $count5 = $count5 + 1  
            Sleep(1000)
        EndIf
        If $count1 = (GUICtrlRead($Down1)) Then    
    ;do something
        EndIf
        If $count2 = (GUICtrlRead($Down2)) Then    
    ;do something
        EndIf

        If $count3 = (GUICtrlRead($Down3)) Then    
    ;do something
        EndIf
;and much more
    WEnd
EndFunc

What does lack that you want?

Link to comment
Share on other sites

Hello Forum,

Im using since some days autoit v3 and try to make an good programm for me but :

I need 2 whiles workign at the same time, but how?

My code where i need it :

$count1 = 0
$count2 = 0
$count3 = 0
$count4 = 0
$count5 = 0

HotKeySet( "{F4}" , "_Train") 
Func _Train()   
    While 1
        If GuiCtrlRead($Checkbox1) = $GUI_CHECKED Then 
            While 2
                $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
            WEnd
        EndIf
        If $count1 = (GUICtrlRead($Down1)) Then 
;do something
        EndIf
        If $count2 = (GUICtrlRead($Down2)) Then 
;do something
        EndIf

        If $count3 = (GUICtrlRead($Down3)) Then 
;do something
        EndIf
;and much more
WEnd
EndFunc

It shall do a countup till the down input, if the count is the same like the input, it shall do another thing.

and all that with 6 things on one time.

The countup doesn't have to be in the funtion.

But it must run up +1 each second, and the other code must workign at the same time.

Maybe my english is a bit bad, and i cant explain good, but please try to help me ;)

If you didn't understood, just ask me :lmao:

Ps. I used the documenation and the search function and google already ;)

More like this (removed references to GUI inputs we don't have):
Global $count1 = 0, $count2 = 0, $count3 = 0, $count4 = 0, $count5 = 0

HotKeySet("{F4}", "_Train")
HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(20)
WEnd

Func _Train()
    AdlibEnable("_Increment", 1000)
    While 1
        If $count1 = 5 Then MsgBox(64, "Five", "Five seconds", 2)
        If $count3 = 10 Then MsgBox(64, "Ten", "Ten seconds", 2)
        If $count5 = 15 Then MsgBox(64, "Fifteen", "Fifteen seconds", 2)
        If $count2 = 20 Then Exit
    WEnd
EndFunc  ;==>_Train

Func _Increment()
    $count1 += 1
    $count2 += 1
    $count3 += 1
    $count4 += 1
    $count5 += 1
EndFunc  ;==>_Increment

Func _Quit()
    Exit
EndFunc  ;==>_Quit

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

That dont really slove my problem: what i would need is a while that is working, while another is working at the same time, like this:

While 1

While 2
;Count up all time here
                $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
Wend
;And while its counting up it shall do other things, 
;More than just use the counts
Wend

ok i think you dont understand this better ;)

I post all my code here that you know what i mean :D

Func _example()
While 1
    While 2
        $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
    WEnd

If GuiCtrlRead($Checkbox1) < $GUI_CHECKED Then;Skill1
;~      If $count1 = (GUICtrlRead($Down1)) Then 
            If GuiCtrlRead($Autoloot) = $GUI_CHECKED Then;Autoloot
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
            Else
    
            EndIf;Autoloot Ende
                            
            ControlSend("Archlord", "", "",(GUICtrlRead($Slot3)));Command senden Skill 1
;~          $count1 = 0
            Sleep ( (GUICtrlRead($Delay3)) );Sleep Skill 1
                
                
            If GuiCtrlRead($Aoe) = $GUI_CHECKED Then;AoE
                ControlSend("Archlord", "", "","{TAB}")
                Sleep( 100 )
            Else
            
            EndIf;AoE Ende
;~      EndIf
    Else
 
    EndIf
Wend
Endfunc

ok i didnt posted all my code that are more than 400 lines ;)

there you see, When its using a skill, its sets the count = 0

and while its using another skills, it shall count up(the dowm time) and only use the skill if the count is already = or < the downtime.

The bot uses skills, and just use one again if the cooltime is already down..

Hope you understood now :lmao:

And it doesn't have to check the downtime like this :cheer: if you know another way just tell me

Edited by eXXe
Link to comment
Share on other sites

Link to comment
Share on other sites

Wow... I don't think you even got as far as running the example.

Heres another one that I hope you will apreciate.

$count = 0
AdlibEnable("myadlib")

While 1
    If $count >= 1000 Then Exit
WEnd

Func myadlib()
    ToolTip("Tool Tip (Count is " & $count & ")")
    $count += 1
EndFunc  ;==>myadlib
Link to comment
Share on other sites

That dont really slove my problem: what i would need is a while that is working, while another is working at the same time, like this:

While 1

While 2
;Count up all time here
                $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
Wend
;And while its counting up it shall do other things, 
;More than just use the counts
Wend

ok i think you dont understand this better ;)

I post all my code here that you know what i mean :D

Func _example()
While 1
    While 2
        $count1 = $count1 + 1  
                $count2 = $count2 + 1  
                $count3 = $count3 + 1  
                $count4 = $count4 + 1  
                $count5 = $count5 + 1  
                Sleep(1000)
    WEnd

If GuiCtrlRead($Checkbox1) < $GUI_CHECKED Then;Skill1
;~      If $count1 = (GUICtrlRead($Down1)) Then 
            If GuiCtrlRead($Autoloot) = $GUI_CHECKED Then;Autoloot
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
            Else
    
            EndIf;Autoloot Ende
                            
            ControlSend("Archlord", "", "",(GUICtrlRead($Slot3)));Command senden Skill 1
;~          $count1 = 0
            Sleep ( (GUICtrlRead($Delay3)) );Sleep Skill 1
                
                
            If GuiCtrlRead($Aoe) = $GUI_CHECKED Then;AoE
                ControlSend("Archlord", "", "","{TAB}")
                Sleep( 100 )
            Else
            
            EndIf;AoE Ende
;~      EndIf
    Else
 
    EndIf
Wend
Endfunc

ok i didnt posted all my code that are more than 400 lines ;)

there you see, When its using a skill, its sets the count = 0

and while its using another skills, it shall count up(the dowm time) and only use the skill if the count is already = or < the downtime.

The bot uses skills, and just use one again if the cooltime is already down..

Hope you understood now :lmao:

And it doesn't have to check the downtime like this :cheer: if you know another way just tell me

It looks to me like PsaltyDS has already given you the solution. You use AdlibEnable to call a function which has your counting in it but without the while 2 like this

Func _example()
AdLIbEnable("Counting",1000);calls the counting function every 1000ms so same as your while 2 loop

While 1
    

If GuiCtrlRead($Checkbox1) < $GUI_CHECKED Then;Skill1
;~      If $count1 = (GUICtrlRead($Down1)) Then 
            If GuiCtrlRead($Autoloot) = $GUI_CHECKED Then;Autoloot
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
                ControlSend("Archlord", "", "","{SPACE}")
                Sleep ( 100 ) 
            Else
    
            EndIf;Autoloot Ende
                            
            ControlSend("Archlord", "", "",(GUICtrlRead($Slot3)));Command senden Skill 1
;~          $count1 = 0
            Sleep ( (GUICtrlRead($Delay3)) );Sleep Skill 1
                
                
            If GuiCtrlRead($Aoe) = $GUI_CHECKED Then;AoE
                ControlSend("Archlord", "", "","{TAB}")
                Sleep( 100 )
            Else
            
            EndIf;AoE Ende
;~      EndIf
    Else
 
    EndIf
Wend
AdLibDisable()
Endfunc

Func Counting()

        $count1 = $count1 + 1  
        $count2 = $count2 + 1  
        $count3 = $count3 + 1  
        $count4 = $count4 + 1  
        $count5 = $count5 + 1  
                
 
endfunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...