Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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 ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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 )
Link to comment
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)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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