Jump to content

loop in another loop


 Share

Recommended Posts

Hi,

I have a loop and I have a timer() func. I would integrate this timer func in my first loop.

$timer = TimerInit()
While TimerDiff($timer) < $duree

; I want put my func timer here ! 
             
WEnd

Func Timer()
    While 1
        _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs )
        $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        ToolTip("Temps restant : " & $TempsRestant,1000,70)
        Sleep(1000)
    WEnd
EndFunc

But like I have my while in my timer() func, my script don't continue :)

thanks

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

  • Moderators

jerem488,

Does this help?

$duree = #####
$timer = TimerInit()

While

If TimerDiff($timer) < $duree Then
        _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs )
        $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        ToolTip("Temps restant : " & $TempsRestant,1000,70)
EndIf
             
WEnd

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

jerem488,

Have you looked at using AdLib? It sounds as though it might be what you are looking for.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

$timer = TimerInit()
$timerDuration = 1000 ; 1 second

While 1
    
    If TimerDiff($timer) > $timerDuration Then
        $timer = TimerInit()
        ConsoleWrite("Resetting Timer" & @CR)   ; If over the timer, reset
    Else
        ConsoleWrite("Executing Code" & @CR)    ; Else, Execute the code repeatedly
    EndIf
    Sleep(100)
WEnd

Is that what you're going for? In that case, to enable your second "loop", you would add an additional statement to the line:

If TimerDiff($timer) > $timerDuration Then

in order to make it more specific.

Link to comment
Share on other sites

I defined the execution time of my script with the $duree variable in a messagebox.

And I want a timer of the remaining time in seconds.

$duree = GUICtrlCreateInput("0", 75, 60, 50, 20)
                               $timer = TimerInit()
                While TimerDiff($timer) < $duree
                    Sleep(Random(500,1000))
                    MouseMove(742, 914)
                    Sleep(500)
                    MouseClick("left")
                    Sleep(Random(9000,10000))
                    MouseMove(290, 220)
                    Sleep(Random(1200,1500))
                    MouseClick("left")
                    Sleep(Random(1000, 1200))
                    MouseMove(742, 914)
                WEnd
Edited by jerem488

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

:) ...?

$timer = TimerInit()
While TimerDiff($timer) < $duree
; I want put my func timer here ! 
Timer()             
WEnd

Func Timer()
    While 1
        _TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs )
        $TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
        ToolTip("Temps restant : " & $TempsRestant,1000,70)
        Sleep(1000)
    WEnd
EndFunc

Cheers, FireFox.

Link to comment
Share on other sites

  • Moderators

jerem488,

Is this what you are looking for?

$timer = TimerInit()
While TimerDiff($timer) < $duree

_TicksToTime(Int($duree - TimerDiff($timer)), $Hour, $Mins, $Secs )
$TempsRestant = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
ToolTip("Temps restant : " & $TempsRestant,1000,70)
  
; Other functions which run in the loop 
             
WEnd

ToolTip("")

Your loop will now run for $duréé ms and carry out other functions and the ToolTip will give $TempsRestant throughout. Do not forget to clear the ToolTip after the loop. ;-)

Si cela n'est pas la solution, explique en francais parce que je n'ai evidemment pas compris la question!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

jerem488,

Now I understand (via PM in French) what you want, my earlier suggestion of AdLib seems to be the answer.

This is an example which shows how to go about it:

GUICreate("AdLib Test", 200, 200)

$Label1 = GUICtrlCreateLabel("Main Loop Count: 0", 10,  10, 180, 20)
$Label2 = GUICtrlCreateLabel("Timer Count: 0", 10, 110, 180, 20)

GUISetState()

AdlibEnable("Timer", 1000)
$Begin = TimerInit()

$i = 1

While 1
    
     Sleep(20000); Replaces your loop functions

     GUICtrlSetData($label1, "Main Loop Count: " & $i)
     $i += 1
    
WEnd

Func Timer()
    GUICtrlSetData($Label2, "Timer Count: " & Int(TimerDiff($Begin) / 1000))
EndFunc

Hope that solves the problem. Ask again if there is something you are unclear about.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

jerem488,

Excellent. 2 things to remember:

1. Do not put too much code in the function called by AdLib.

2. Disable AdLib when you no longer need it or it eats CPU time unnecessarily.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...