Sign in to follow this  
Followers 0
some1

Sleep ( $sleep-time )... Is this possible?

12 posts in this topic

Hi

I'm making a Internet connection monitor. On my gui, I need to be able to set the time between connection attemps. I have tried with:

While $Monitoring = 1

;;alot of code

Sleep ( $Interval )

but the interval is not the same value as $Interval... Only when I put in a number (like 5000), there is a delay...

Can it be done this way??? Or if not, would you be so kind to tell me how to do it right :whistle:

thx

Share this post


Link to post
Share on other sites



Hi

I'm making a Internet connection monitor. On my gui, I need to be able to set the time between connection attemps. I have tried with:

While $Monitoring = 1

;;alot of code

Sleep ( $Interval )

but the interval is not the same value as $Interval... Only when I put in a number (like 5000), there is a delay...

Can it be done this way??? Or if not, would you be so kind to tell me how to do it right :whistle:

thx

Should work ...what is the problem you are seeing ?

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

For sleep times

I do something like this to make a random sleep between x1 and x2 numbers.

$sleep = Random(5000,6000)

Sleep($sleep); sleeps between 5 and 6 seconds

hope that helps.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

what is the problem you are seeing?

There is no sleep-time... its like i have just entered:

sleep ()

For sleep times

I do something like this to make a random sleep between x1 and x2 numbers.

$sleep = Random(5000,6000)

Sleep($sleep); sleeps between 5 and 6 seconds

hope that helps.

I am really glad about the help commin' in so fast, but the thing I want to do, is to put in a sleep-time in the gui, not just have a random sleep-time. Edited by some1

Share this post


Link to post
Share on other sites

oh sorry im not very good at autoit jus learning.dun no ne thing about gui. im still trying to figure out how 2 make it where the script will relise that the monster im attacking is dead -.- that way i dont have 2 time how long it usally takes me 2 kill it and hope its dead by then.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

There is no sleep-time... its like i have just entered:

sleep ()

I am really glad about the help commin' in so fast, but the thing I want to do, is to put in a sleep-time in the gui, not just have a random sleep-time.

Show what your are doing and be a bit more clear in the problem description. Sleep($time) will work when $time contains the time to pause in ms.

:whistle:

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi

I'm making a Internet connection monitor. On my gui, I need to be able to set the time between connection attemps. I have tried with:

While $Monitoring = 1

;;alot of code

Sleep ( $Interval )

but the interval is not the same value as $Interval... Only when I put in a number (like 5000), there is a delay...

Can it be done this way??? Or if not, would you be so kind to tell me how to do it right :whistle:

thx

try this

While $Interval = random(1000,9000) ; sleep between 1-9 secs

;;alot of code

Sleep ( $Interval )

Share this post


Link to post
Share on other sites

ok, here is the code for my function:

;;================================================================================
;;Function
;;================================================================================
While 1
    
    $msg = GUIGetMsg()
    
    Select
        
    Case $msg = $GUI_EVENT_CLOSE
        
            Exit
            
        Case $msg = $CheckNow
            
            $Interval = GUICtrlRead($Interval)
            $IP = GUICtrlRead($IP)
            $IntervalReal = $Interval * 1000
                        
            Traytip ( $AppName, "Checking connection", 1500)
            
            $Ping = ping ( "209.166.161.121" )
            MsgBox (0, $AppName, $Connection)

        Case $msg = $Monitor
            
            $Interval = GUICtrlRead($Interval)
            $IP = GUICtrlRead($IP)
            $IntervalReal = $Interval * 1000
            
            $Monitoring = 1
            
            Traytip ( $AppName, "Monitoring connection", 1500)
            
                While $Monitoring = 1
                    
                    $msg = GUIGetMsg()
                    
                    If $msg = $CheckNow Then
                        
                        Traytip ( $AppName, "Checking connection", 1500)
                        
                        $Ping = ping ( "209.166.161.121" )
                        MsgBox (0, $AppName, $Connection)
                        
                    EndIf
                    
                    If $msg = $GUI_EVENT_CLOSE Then
                        
                        Exit
                        
                    EndIf
                    
                    If $msg = $Monitor Then
                        
                        $Monitoring = 0
                        
                    EndIf
                    
                    $Ping = ping ( "209.166.161.121" )
                    MsgBox (0, $AppName, $Connection)
                    
                    MsgBox ( 0, $AppName, "Your Connection is being checked")
                    [b]sleep ( $IntervalReal )[/b]
                
                WEnd
                
    EndSelect

Wend

The $Interval is filled in by the user in the gui... This value is then made to millisecs, and the Value put into $IntervalReal, Which is the sleep-value...

Donøt worry about all the msgBox'es... it was just to see if the program even reacted to pressing buttons, and hotkeys :whistle: (still learning)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

you should not do this :

$Interval = GUICtrlRead($Interval)

I assume that $Interval contains the ControlHandle of the GuiCreateInput() and you overide it with its content .....

Use a different variablename for the read value and try again.

Also for debugging, check the calculated value for $IntervalReal ...

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

ok, will be back in ten minutes...

Share this post


Link to post
Share on other sites

Damn... That did it :whistle:

Thx ALOT (to you all, Great Community)

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