haijie1223 Posted March 25, 2017 Share Posted March 25, 2017 On 2011/12/19 at 3:05 AM, KaFu said: Give this one a try... $h_DLL_NtDll = DllOpen("ntdll.dll") $Delay_value = GUICtrlRead($Delay) If WinExists("Notepad") Then WinActivate("Notepad") _HPSleep($Delay_value) Else MsgBox(0, "Wrong Window", "Open Up Nitto n00b") EndIf Func _HPSleep($fMs = 1) ; http://www.autoitscript.com/forum/topic/77905-sleep-down-to-100-nano-seconds/page__view__findpost__p__862689 ; default is milliseconds, otherwise microseconds (1 ms = 1000 µs) DllCall($h_DLL_NtDll, "dword", "NtDelayExecution", "int", 0, "int64*", -10000 * $fMs) ; ~ 1ms EndFunc ;==>_HPSleep Why the Second param *(-1) Link to comment Share on other sites More sharing options...
Subz Posted March 25, 2017 Share Posted March 25, 2017 You do realise this is a 6 year old post? What param are you referring to? Link to comment Share on other sites More sharing options...
KaFu Posted March 25, 2017 Share Posted March 25, 2017 https://forum.powerbasic.com/forum/user-to-user-discussions/source-code/56824-ntdelayexecution-sleep-sleepex-with-higher-resolution-absolute-delay Quote NtDelayExecution() takes a 64-bit integer (QUAD) as the time-to-sleep, vs 32-bit (DWORD) for Sleep()/SleepEx(). If this is a NEGATIVE integer it specifies the relative time to sleep (in units of 100 nanoseconds), otherwise it specifies the absolute time to wake up (the latter being a feature of it which neither Sleep()/SleepEx() cater for -- we have to call NtDelayExecution directly to use that feature).Example, using relative time, for the equivalent to Sleep(2500), ie. sleep for 2.5 seconds, we specify -25000000 as the interval with NtDelayExecution(). Using absolute time (which is exclusive to NtDelayExecution and cannot be used via Sleep/SleepEx) we simply get the current system time (UTC, so we use GetSystemTime not GetLocalTime), convert that to filetime, and add 25000000 to the dwLowDateTime field. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
haijie1223 Posted March 28, 2017 Share Posted March 28, 2017 On 2017/3/25 at 5:03 PM, KaFu said: https://forum.powerbasic.com/forum/user-to-user-discussions/source-code/56824-ntdelayexecution-sleep-sleepex-with-higher-resolution-absolute-delay Thanks 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