Jump to content

Sleep() problem!


SugarBall
 Share

Recommended Posts

Hello guys, 

suddenly i'm having a problem with Sleep() func. When i give it less time like Sleep(2000), works, but when i tell it to sleep longer like Sleep(1000*60*3), it won't work... in fact is a surprise because it used to work perfectly.. anyone knows how to help?

SugarBall

Link to comment
Share on other sites

No, still doesn't works... pretty weird!!

Doesn't work means less than nothing to us, what doesn't work?

  • It doesn't sleep the script? 
  • the script didn't sleep as long as you're expecting?
  • the script sleeps longer than you're expecting?
  • the script crashes?
  • the script locks up?
  • the computer blue screens?
  • the computer catches on fire?

 Help us help you, give us more than "it doesn't work".

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

No #requireAdmin and yes i am running compiled!....

it is the script of the AdLibRegister example... and i have changed the time to sleep longer... it used to work days before, and now no... no changes made at all...

If ProcessExists("SciTE.exe") = 0 Then
    MsgBox($MB_SYSTEMMODAL, "", "You will need SciTE.exe to be running for ConsoleWrite to display.")
EndIf

Example()

Func Example()
    
    AdlibRegister("MyAdLibFunc")

    
    Sleep(1000)   ;<<<<<<<<<<======================= IT WORKS BrewManNH

    
    MsgBox($MB_SYSTEMMODAL, "", "No console message(s) will be shown whilst the messagebox is displayed.")

    
    Sleep(180000) ; <<<<<<<======= my problem... it wont stop the script

    
    AdlibUnRegister("MyAdLibFunc")
EndFunc   

Func MyAdLibFunc()
    
    Local Static $iCount = 0
    $iCount += 1

    ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF)
EndFunc

 

Edited by SugarBall
Link to comment
Share on other sites

I'd say it's something wrong or different on your computer, it works fine for me and for thousands of other people.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As I said I, and thousands of other users, are not having any problems with the sleep function, or we would have heard something about it. You're an isolated case, you're having a problem no one else is complaining about, nor can we replicate the issue. So, logically, your computer or software on your computer, or something related to something you're doing is at fault and not AutoIt and/or the sleep function contained within it.

Asking us whether or not the function is working for us would be the logical question, not asking what is wrong with sleep (that no one else is experiencing). As far as we know, there's nothing wrong with the Sleep function, because it is working as intended for us.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Is your problem that "MyAdLibFunc" continues to be called and print to the console during the execution of "Sleep"?  If so, that is expected behavior.

Perhaps you want something more to the effect of this?

Func _WinAPI_Sleep($nMilliseconds)
    DllCall("Kernel32.dll", "NONE", "Sleep", "DWORD", $nMilliseconds)
EndFunc

 

Edited by Tekk
Link to comment
Share on other sites

As I said before, it's NOT happening for anyone else but you, regardless of the length of the sleep time. If it were we would have heard about it before this. My logic is not the issue, you are fixated on the idea that Sleep isn't working.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

As JohnOne said, Sleep is not really blocking (so it does not block an adlib registered function.

Instead, you can use a alternative like this :

AdlibRegister("MyAdLibFunc")

Sleep(2000)
_Sleep(2000)


Func MyAdLibFunc()
    Local Static $iCount = 0
    $iCount += 1

    ConsoleWrite("MyAdLibFunc called " & $iCount & " time(s)" & @CRLF)
EndFunc

Func _Sleep($iDelay)
    DllCall("Kernel32.dll", "none", "Sleep", "dword", $iDelay)
EndFunc

 

Edited by jguinch
Link to comment
Share on other sites

Sleep is a series of internal 10ms calls to the API jguinch posted above, exactly so it can be interrupted.

EDIT: unless the internal calls are 1000ms, that's the only reason I can see why

Sleep(1000)   ;<<<<<<<<<<======================= IT WORKS

would work, since the default time of adlib is 250ms

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

×
×
  • Create New...