Sign in to follow this  
Followers 0
jerem488

loop in another loop

14 posts in this topic

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]

Share this post


Link to post
Share on other sites



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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

no, not really.... because the script I execute in the first loop exceeds 1second ! !

So the timer change every (((the time of the loop))) ! !


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

Share this post


Link to post
Share on other sites

jerem488,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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]

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Euh................... :) How expalin the problem...........

I have already a loop that lasts about 3minutes. And during this loop, I want in fact a timer of the remaining time in seconds....


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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

A very simple example.

For $i = 0 To 9
    Sleep(1000)
    ConsoleWrite(9-$i &@CR)
Next

I know it's very unreliable but you get the point.

Edited by Pain

Share this post


Link to post
Share on other sites

yes ! ! But the loop continue when the timer is finished ! !

Nearly me, I want the timer tun when the loop run !


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

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Yes ! ! It's this !

Very thanks ! ! I didn't know this function. Now, I could use !

Topic resolved ]]]]]]]]]]] ! ! !

Thnks M23 ! :)

Edited by jerem488

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

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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