Dimmak Posted August 20, 2012 Share Posted August 20, 2012 I use dll function to get sleep(1): _Sleep(1) Func _Sleep($ms) DllCall($dll_kernel32, "DWORD", "Sleep", "int", $ms) EndFunc Function allow to get sleep in range from 0.3 to 1.1ms, but how to set float sleep ( for examle 0.05ms ) and make it more stable? Please help! Link to comment Share on other sites More sharing options...
Andreik Posted August 20, 2012 Share Posted August 20, 2012 You would like When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dimmak Posted August 20, 2012 Author Share Posted August 20, 2012 Thanx Andreik, I have tested many examples from your link, but are stable only timer and timer functions ( eat cpu ), and minimal sleep in range from 0.6 - 1.1ms. Link to comment Share on other sites More sharing options...
Andreik Posted August 20, 2012 Share Posted August 20, 2012 Where did you find these ranges? And the parameter of the function is a dword, this mean your value will be truncated if you pass a float. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dimmak Posted August 20, 2012 Author Share Posted August 20, 2012 Where did you find these ranges?$starttime = _Timer_Init() _hpSleep(1) $endtime = _Timer_Diff($starttime)And the parameter of the function is a dword, this mean your value will be truncated if you pass a float.I set integer( for example ):_Sleep(1) Func _Sleep($ms) DllCall($dll_kernel32, "DWORD", "Sleep", "int", $ms) EndFuncBut sleep value is between 0.3 ~ 1.1ms. Link to comment Share on other sites More sharing options...
Andreik Posted August 20, 2012 Share Posted August 20, 2012 Ok, and what do want to accomplish? This range I'm sure it's variable because of interpreting and other things. It has nothing to do with stability if you set some rounded float values, the result it's not accurate in this way. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dimmak Posted August 21, 2012 Author Share Posted August 21, 2012 (edited) So this is the minimum possible value for autoit!? I just want to find this out. Edited August 21, 2012 by Dimmak Link to comment Share on other sites More sharing options...
Andreik Posted August 21, 2012 Share Posted August 21, 2012 It's not AutoIt related as long you call it through DllCall. You don't call a function with what kind of parameters types you want. You must do it according to documentation. If you need to specify a dword then you must do that. If you pass a float the value will be truncated.When the value is 0:A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. This behavior changed starting with Windows Server 2003.When the value is INFINITE:A value of INFINITE indicates that the suspension should not time out. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dimmak Posted August 21, 2012 Author Share Posted August 21, 2012 OK! Andreik I need stable sleep 0.5ms. Can you help me do this, please! Link to comment Share on other sites More sharing options...
Andreik Posted August 21, 2012 Share Posted August 21, 2012 Man you really don't understand you can't pass a float instead of dword in Sleep function from kernel32.dll and then expect to work as you wish? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 21, 2012 Moderators Share Posted August 21, 2012 Dimmak, I need stable sleep 0.5msThere will always be some variablility in the result because of the inherent difference between the timer chips in different machines (jchd explains it much better here) so I do not believe you can ever achieve your target. Add to this the fact that AutoIt needs to interpret the DllCall each time which in itself adds to the variability.... Why do you need such a short Sleep and why is it important for it to be so "stable"? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Dimmak Posted August 22, 2012 Author Share Posted August 22, 2012 AndreikAs I know kernel32.dll is not the only one dll in the universe. Maybe other dll...Melba23Short sleep need because Autoit works in single thread. And run multiple scripts, the only solution, I think.Without sleep - very fast, but cpu overload. With sleep slower but less cpu usage. I was looking for a center between these 2 points.And stable... I just want to know the possibilities of the Autoit. Step by step. One step closer. Link to comment Share on other sites More sharing options...
Andreik Posted August 22, 2012 Share Posted August 22, 2012 It's not about name of dll you may use but you must understand that every DllCall it takes some time to be called and this execution time may vary. In this case you cannot make a very accurate sleep. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Dimmak Posted August 22, 2012 Author Share Posted August 22, 2012 Yes! I've already realized this. Thanx. Link to comment Share on other sites More sharing options...
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