DarksSaber Posted April 30, 2023 Share Posted April 30, 2023 I was working on some tools and was able to get the mousedown and mouseup clicks to go pretty fast. Mouseclicks were registering at 1 ms or instant. After updating my BIOS (due to the recent AMD AM5 issues), the click speeds are now taking around 10-16 ms. I am using mousedown/mouseup as those were faster than mouseclick even with the AutoItSetOption("mouseclicdelay", 0) and AutoItSetOption("mouseclickdowndelay", 0) set. I have tried reverting back to the previous BIOS and checked my BIOS settings to ensure everything else was the same as before but can't seem to get back to the speeds I was at before. Anyone have any ideas on what else would contribute to click speeds to be a lot slower? I thought possibly because I have stuff running on my PC but I tried having everything shut down and still slower while before I was getting the much faster speeds with quite a few things running. Below is just something to test the click speeds. It's also a bit weird that when spamming one of the hotkeys, the times also vary. For Test and Test3, I'll sometimes get 0.001 seconds and then sometimes it will be above 0.010 seconds. For Test2, its anywhere between 0.020 to 0.0.0 seconds (which is expected since the default mouseclickdelay and mouseclickdowndelay are 10 ms each). Any assistance or suggestions would be greatly appreciated. Quote Global $sFilePathTimer = @ScriptDir & "\Timer.txt" $hFileOpen = FileOpen($sFilePathTimer, 1) Global $Paused = False Global $hTimer Global $fDiff Global $TimerSeconds Global $iRound1 HotKeySet("{ESC}", "Terminate") HotKeySet("{1}", "Test") HotKeySet("{2}", "Test2") HotKeySet("{3}", "Test3") Func Test() $hTimer = TimerInit() MouseDown("left") MouseUp("left") $fDiff = TimerDiff($hTimer) $TimerSeconds = $fDiff/1000 $iRound1 = round($timerSeconds,3) FileWrite($hFileOpen, "Click Time" & $iRound1 & " seconds." & @CRLF) EndFunc Func Test2() $hTimer = TimerInit() mouseclick("left") $fDiff = TimerDiff($hTimer) $TimerSeconds = $fDiff/1000 $iRound1 = round($timerSeconds,3) FileWrite($hFileOpen, "Click Time" & $iRound1 & " seconds." & @CRLF) EndFunc Func Test3() AutoItSetOption("MouseClickDelay", 0) AutoItSetOption("MouseClickDownDelay", 0) $hTimer = TimerInit() mouseclick("left") $fDiff = TimerDiff($hTimer) $TimerSeconds = $fDiff/1000 $iRound1 = round($timerSeconds,3) FileWrite($hFileOpen, "Click Time" & $iRound1 & " seconds." & @CRLF) AutoItSetOption("MouseClickDelay", 10) AutoItSetOption("MouseClickDownDelay", 10) EndFunc While $paused = False sleep(10) WEnd Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted April 30, 2023 Developers Share Posted April 30, 2023 Mmm. Spamming...speed...mouseclick == game automation. Yes/No. ( and explain pls) Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DarksSaber Posted April 30, 2023 Author Share Posted April 30, 2023 It's not for game automation. I'm using some tools to compare responses of software used for keyboards and mice or Stream Deck software as I've seen different company software react differently. I noticed when testing things between Corsair, Razer, Logitech, and Stream Deck software that putting in the same settings on them don't always work at the same times or speeds. I had a script that I was using to compare if what is stated in their software matched closely or not. After updating my mobo's BIOS from the recent AM5 debacle, this started acting oddly. After checking through a bunch of things, I found out that the click speeds seem to be acting inconsistently and also at a much slower speed. I'm just trying to figure out what would have caused this. Link to comment Share on other sites More sharing options...
mistersquirrle Posted April 30, 2023 Share Posted April 30, 2023 (edited) My guess to this would likely be timer resolution in Windows, you can read more about that here: https://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ and some other places, I don't know of a great source that talks about it. However, taking 10-16ms sounds very much like it's around the default Windows timer resolution of 15.6ms or so. Some programs will request/set the system to a higher resolution, generally 1ms is the lowest, but there may be some settings that you have to enable/disable to get it there. If you check out this thread, there's an example of how to enable the higher resolution/precision timer, though doing so is not always the best for overall system performance or power usage: Also when posting code, use the code formatting option: And another note about MouseClick, it has a built-in sleep of 10ms, you can't get around that with MouseClick and would have to use a different function for clicking repeatedly faster. There's some fast mouse click examples on the forum already. Edited April 30, 2023 by mistersquirrle We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
Lepes Posted May 1, 2023 Share Posted May 1, 2023 Not sure if this helps.... If you want to measure with precision, you can use: Link to comment Share on other sites More sharing options...
mistersquirrle Posted May 1, 2023 Share Posted May 1, 2023 @Lepes I don't think that this is a good method for measuring time with precision, at least over native AutoIt function. I did a quick test comparing that linked function vs just TimerInit and TimerDiff: Func _MicroSeconds() Local Static $nFreq = _WinAPI_QueryPerformanceFrequency() Local $a = _WinAPI_QueryPerformanceCounter() Local $b = _WinAPI_QueryPerformanceCounter() Return (($b - $a) / $nFreq) * 1000000 EndFunc ;==>_MicroSeconds Func _TimerDiff() Local $hTimer = TimerInit() Local $nOutput = TimerDiff($hTimer) * 1000 Return $nOutput EndFunc ;==>_TimerDiff And the speed output: 2023-05-01 09.54.18.626: _MicroSeconds: 13.5 2023-05-01 09.54.18.627: _TimerDiff: 3.2 [================== Run progress, 100,000 times * 2 functions =================] +———————————————+—————————————————+———————————————+——————————————+—————————————+ | Function Name | Time Taken (ms) | Avg Time (ms) | Std Dev (ms) | Faster By % | +———————————————+—————————————————+———————————————+——————————————+—————————————+ | _MicroSeconds | 3288.67 | 0.0329 | 0.0170 | 0.00 | +| _TimerDiff | 396.91 | 0.0040 | 0.0082 | 87.93 | +———————————————+—————————————————+———————————————+——————————————+—————————————+ As you can see _MicroSeconds gave me 13.5us, _TimerDiff 3.2us, and comparing them TimerInit() and TimerDiff() are 87% faster. It can't measure as low as the native functions since they run so much faster. It's likely/possible that TimerInit uses QueryPerformanceCounter or GetTickCount internally anyway, and its internal method of calling these is just a lot faster than a DLL call. Also we're not looking at trying to measure sub-millisecond precision here, and even if _WinAPI_QueryPerformanceCounter was as fast/faster, I think it's still a bit simpler to use TimerInit/TimerDiff. Lepes 1 We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
Zedna Posted May 3, 2023 Share Posted May 3, 2023 Look at my MouseClickFast & MouseMoveFast: Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
DarksSaber Posted May 6, 2023 Author Share Posted May 6, 2023 On 4/30/2023 at 2:58 PM, mistersquirrle said: My guess to this would likely be timer resolution in Windows, you can read more about that here: https://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ and some other places, I don't know of a great source that talks about it. However, taking 10-16ms sounds very much like it's around the default Windows timer resolution of 15.6ms or so. Some programs will request/set the system to a higher resolution, generally 1ms is the lowest, but there may be some settings that you have to enable/disable to get it there. If you check out this thread, there's an example of how to enable the higher resolution/precision timer, though doing so is not always the best for overall system performance or power usage: Also when posting code, use the code formatting option: And another note about MouseClick, it has a built-in sleep of 10ms, you can't get around that with MouseClick and would have to use a different function for clicking repeatedly faster. There's some fast mouse click examples on the forum already. Thanks for the replies. Not sure what's going on but seems to have been an issue on my PC dealing with configurations for the x3D processors. Not sure what changed but things started working at the expected speed again. Might have had to do with processes moving back and forth between the 2 CCDs so was incurring some latency. I figured that out about mouseclick so I just use mousedown and mouseup. I have been using the high precision sleep for a bit now and it works great. I'll use the code tags in the future. Thanks for that as well. Link to comment Share on other sites More sharing options...
DarksSaber Posted May 6, 2023 Author Share Posted May 6, 2023 On 5/3/2023 at 7:27 PM, Zedna said: Look at my MouseClickFast & MouseMoveFast: I'll take a look and give those a try. The mousemovefast looks like it can be an improvement. How does the click speed compare to mousedown/mouseup? I've been using this instead of mouseclick. mousemove($x, $y, 0) mousedown("left") mouseup("left") Link to comment Share on other sites More sharing options...
mistersquirrle Posted May 7, 2023 Share Posted May 7, 2023 3 hours ago, DarksSaber said: How does the click speed compare to mousedown/mouseup? MouseClick speeds can really depend on what you're actually clicking, when you click fast. I did this test against just a blank GUI that I created, so that there shouldn't be anything for the clicks to 'do'. [==================== Run progress, 10,000 times * 2 functions =====================] +————————————————————+—————————————————+———————————————+——————————————+—————————————+ | Function Name | Time Taken (ms) | Avg Time (ms) | Std Dev (ms) | Faster By % | +————————————————————+—————————————————+———————————————+——————————————+—————————————+ +| __Test_MouseUpDown | 12490.64 | 1.2491 | 1.8789 | 22.06 | | _MouseClickFast | 16025.17 | 1.6025 | 2.5813 | 0.00 | +————————————————————+—————————————————+———————————————+——————————————+—————————————+ But this test is fairly inconsistent, I've seen it go either way for which is faster. I would just recommend to use whatever you're more comfortable with, and whichever works. We ought not to misbehave, but we should look as though we could. 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