Sign in to follow this  
Followers 0
glix

loop getting in the way

8 posts in this topic

#1 ·  Posted (edited)

im fairly new to auto it and i cant get these to loop together, it only loops the first one in order. the gui menu also is on a loop so im assuming they must all be incorporated somehow. i want the first one to click and wait 10 minutes and the next one to immediatley follow it then wait 6 and a half minutes until it redoes the process.

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("title", 225, 145, 93, 15)
$Button2 = GUICtrlCreateButton("Exit", 50, 70, 90, 25, 0)
$Label1 = GUICtrlCreateLabel("GLIX", 50, 110, 90, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$KeepLooping = 1
$Count = -1
Sleep (1500)
While 1
    Send ("d8")
    Sleep (500)
    Mousemove (311, 172)
    Sleep (500)
    MouseClick ("left")
    Sleep(602000)
WEnd

While 1 
    Send ("d1")
    Sleep (500)
    Mousemove (319, 174)
    Sleep (500)
    MouseClick ("left")
    Sleep(394000)
WEnd


While $KeepLooping
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         
        Case $Button2 
            $KeepLooping = 0

    EndSwitch
    
    If $Count >= 0 Then
        $Count = $Count + 1
        GUICtrlSetData($Label1, $Count)
    EndIf
    
WEnd
Edited by glix

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

maybe...

#include <GUIConstants.au3>

Global $Count = -1
Global $KeepLooping = 0

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Looper", 225, 145, 93, 15)
$Button2 = GUICtrlCreateButton("Start", 50, 70, 90, 25, 0)
$Label1 = GUICtrlCreateLabel("GLIX", 50, 110, 90, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button2
            If $KeepLooping = 0 Then
                GUICtrlSetData($Button2, "Stop")
                $KeepLooping = 1
            Else
                GUICtrlSetData($Button2, "Start")
                $KeepLooping = 0
            EndIf
    EndSwitch

    If $KeepLooping Then Dothis()
    If $KeepLooping Then Dothat()
    
    If $Count >= 0 Then
        $Count = $Count + 1
        GUICtrlSetData($Label1, $Count)
    EndIf

WEnd

Func Dothis()
  
    Send("d8")
    Sleep(500)
    MouseMove(311, 172)
    Sleep(500)
    MouseClick("left")
    Sleep(602000)
EndFunc   ;==>Dothis

Func Dothat()
  
    Send("d1")
    Sleep(500)
    MouseMove(319, 174)
    Sleep(500)
    MouseClick("left")
    Sleep(394000)
EndFunc   ;==>Dothat

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

that helped a bunch, but now i need help with functions, how can i get it so they run at the same time rather then whenever that hotkey is pressed limiting it to one series of a function loop at a time.

Func locate() 
     While 1
        $coord = PixelSearch (0, 36, 619, 335,  0xFFFFDE)   
        If Not @error Then
    MouseClick("Right", $coord[0],  $coord[1])
    Sleep (1000)
    
    Endif
    WEnd
EndFunc

Func gather()
    While 1
        $color = PixelGetColor(313, 232)
If $color = 0xF78E18 Then 
    Send ("b")
    Sleep (1000)
EndIf
WEnd
EndFunc


Func cast()
    while 1
$mspg = PixelGetColor(56, 414)
If $mspg = 0x8CEBF7 Then
    Send ("a3d9") 
    sleep (1100)
    send ("a3d")
EndIf
WEnd
EndFunc

Share this post


Link to post
Share on other sites

While 1
    locate()
    cast()
    gather()
    Sleep(10)
WEnd

Func locate()

    $coord = PixelSearch(0, 36, 619, 335, 0xFFFFDE)
    If Not @error Then
        MouseClick("Right", $coord[0], $coord[1])
        Sleep(1000)
    EndIf

EndFunc   ;==>locate

Func gather()

    $color = PixelGetColor(313, 232)
    If $color = 0xF78E18 Then
        Send("b")
        Sleep(1000)
    EndIf

EndFunc   ;==>gather


Func cast()

    $mspg = PixelGetColor(56, 414)
    If $mspg = 0x8CEBF7 Then
        Send("a3d9")
        Sleep(1100)
        Send("a3d")
    EndIf

EndFunc   ;==>cast

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Looper", 225, 145, 93, 15)
$Button2 = GUICtrlCreateButton("Start", 50, 70, 90, 25, 0)
$Label1 = GUICtrlCreateLabel("GLIX", 50, 110, 90, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
sleep (3000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button2
            If $KeepLooping = 0 Then
                GUICtrlSetData($Button2, "Stop")
                $KeepLooping = 1
            Else
                GUICtrlSetData($Button2, "Start")
                $KeepLooping = 0
            EndIf
    EndSwitch

    If $KeepLooping Then aite()
    If $KeepLooping Then fas()
    If $KeepLooping Then mspg()
    If $KeepLooping Then locate()
    If $KeepLooping Then gather()
    
    If $Count >= 0 Then
        $Count = $Count + 1
        GUICtrlSetData($Label1, $Count)
         cast()
    gather()
    EndIf    
WEnd

Func aite()
    Send ("d8")
    Sleep (500)
    Mousemove (311, 190)    ; must come back to these commands after 605 seconds but continue on with the rest
    Sleep (500)
    MouseClick ("left")
    Sleep(605000)
EndFunc

Func fas()
    Send ("d1")
    Sleep (500)
    Mousemove (319, 174) ; come back to commands in 395 seconds but continue with bottom 3 functions while not executing func fas and aite
    Sleep (500)
    MouseClick ("left")
    Sleep(395000)
EndFunc

Func mspg()
    
$mspg = PixelGetColor(56, 414)
If $mspg = 0x8CEBF7 Then
    Send ("a3d9") 
    sleep (1100)
    send ("a3d")
EndIf
EndFunc

 Func locate() 
        $coord = PixelSearch (0, 36, 619, 335,  0xFFFFDE)   
        If Not @error Then
    MouseClick("Right", $coord[0],  $coord[1])
    Sleep (1500)
    
    Endif
EndFunc

Func gather()
        $color = PixelGetColor(313, 232)
If $color = 0xF78E18 Then
    Send ("b")
    Sleep (1000)
    EndIf
EndFunc

The functions all work in a loop, but when i set the first function's sleep time, thats how long it waits for instead of skipping to the next function, so 605 seconds of waiting time until func 2 is activated.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

Global $Count = 1
Global $KeepLooping = 0
Global $aite_time = TimerInit(), $aite_diff
Global $fas_time = TimerInit(), $fas_diff

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Looper", 225, 145, 93, 15)
$Button2 = GUICtrlCreateButton("Start", 50, 70, 90, 25, 0)
$Label1 = GUICtrlCreateLabel("GLIX", 50, 110, 90, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Sleep(3000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button2
            If $KeepLooping = 0 Then
                GUICtrlSetData($Button2, "Stop")
                $KeepLooping = 1
            Else
                GUICtrlSetData($Button2, "Start")
                $KeepLooping = 0
            EndIf
    EndSwitch

    If $KeepLooping Then aite()
    If $KeepLooping Then fas()
    If $KeepLooping Then mspg()
    If $KeepLooping Then locate ()
    If $KeepLooping Then gather()

    If $Count >= 0 Then
        $Count = $Count + 1
        GUICtrlSetData($Label1, $Count)
        ;cast() no Function here???
        gather()
    EndIf
WEnd

Func aite()
    $aite_diff = TimerDiff($aite_time)
    If $aite_diff <= "605000" Then Return
    Send("d8")
    Sleep(500)
    MouseMove(311, 190)    ; must come back to these commands after 605 seconds but continue on with the rest
    Sleep(500)
    MouseClick("left")
    $aite_time = TimerInit()
EndFunc   ;==>aite

Func fas()
    $fas_diff = TimerDiff($fas_time)
    If $fas_diff <= "395000" Then Return
    Send("d1")
    Sleep(500)
    MouseMove(319, 174) ; come back to commands in 395 seconds but continue with bottom 3 functions while not executing func fas and aite
    Sleep(500)
    MouseClick("left")
    $fas_time = TimerInit()
EndFunc   ;==>fas

Func mspg()

    $mspg = PixelGetColor(56, 414)
    If $mspg = 0x8CEBF7 Then
        Send("a3d9")
        Sleep(1100)
        Send("a3d")
    EndIf
EndFunc   ;==>mspg

Func locate ()
    $coord = PixelSearch(0, 36, 619, 335, 0xFFFFDE)
    If Not @error Then
        MouseClick("Right", $coord[0], $coord[1])
        Sleep(1500)

    EndIf
EndFunc   ;==>locate

Func gather()
    $color = PixelGetColor(313, 232)
    If $color = 0xF78E18 Then
        Send("b")
        Sleep(1000)
    EndIf
EndFunc   ;==>gather

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

thanks got it working perfectly :)

Share this post


Link to post
Share on other sites

thanks got it working perfectly :)

Welcome....

this was just fun for me...

remember... don't expect anyone to just write your scripts for you,

..... like I just did

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0