SugarBall Posted September 27, 2015 Posted September 27, 2015 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
computergroove Posted September 27, 2015 Posted September 27, 2015 I doubt that its the multiplying but what happens if you try sleep(180000)? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 (edited) No, still doesn't works... pretty weird!! Edited September 27, 2015 by SugarBall definitive answer
JohnOne Posted September 27, 2015 Posted September 27, 2015 it won't workit doesn't worksElaborate. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
BrewManNH Posted September 27, 2015 Posted September 27, 2015 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". water 1 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 GudeHow 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
JohnOne Posted September 27, 2015 Posted September 27, 2015 Are you running compiled or not?#RequireAdmin or not? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 (edited) 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 September 27, 2015 by SugarBall
BrewManNH Posted September 27, 2015 Posted September 27, 2015 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 GudeHow 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
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 (edited) No man it has nothing to do with my computer... try your logic a bit! It works for less time and in other scripts....why not specificlly there?? Edited September 27, 2015 by SugarBall
BrewManNH Posted September 27, 2015 Posted September 27, 2015 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 GudeHow 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
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 Ok guy....your logic failed you again!sure sleep function would work fine for everyone else, why wouldn't??PS: try to read my comments completely and clearly
Tekk Posted September 27, 2015 Posted September 27, 2015 (edited) 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 September 27, 2015 by Tekk
BrewManNH Posted September 27, 2015 Posted September 27, 2015 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 GudeHow 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
JohnOne Posted September 27, 2015 Posted September 27, 2015 Adlib will interrupt Sleep function. SugarBall 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 (edited) @BrewManNHi know is happening only for me!im not fixated with the idea that Sleep doesnt works, I AM HAVING A PROBLEM! lets drop this conversation if you cant help me! @JohnOnebut why? that is what i thought in the first place.. Edited September 27, 2015 by SugarBall
jguinch Posted September 27, 2015 Posted September 27, 2015 (edited) 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 September 27, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
JohnOne Posted September 27, 2015 Posted September 27, 2015 (edited) 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 whySleep(1000) ;<<<<<<<<<<======================= IT WORKSwould work, since the default time of adlib is 250ms Edited September 27, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
SugarBall Posted September 27, 2015 Author Posted September 27, 2015 Thank you very much both of you jguinch and JohnOne,My imagination thought of something like your code jguinch
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now