Jump to content

Sleep less than 1


 Share

Recommended Posts

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

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)
EndFunc

But sleep value is between 0.3 ~ 1.1ms.

Link to comment
Share on other sites

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

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

  • Moderators

Dimmak,

I need stable sleep 0.5ms

There 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.... :wacko:

Why do you need such a short Sleep and why is it important for it to be so "stable"? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Andreik

As I know kernel32.dll is not the only one dll in the universe. Maybe other dll...

Melba23

Short 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

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