Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Accurate timer



  • Please log in to reply
11 replies to this topic
montyburly
  • Members
  • 5 posts
  • Last active: May 24 2015 07:55 AM
  • Joined: 12 May 2015

.



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

SetTimer, Sub_ClickMouse, 100 ; Check every 1ms

 

100 = 100ms

 

Try it with less.

 

 

Also Click is effected by sendmode.

 

Put at top of script

SendMode, Input


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

A bit simplified:

#Persistent
SetTimer, Sub_ClickMouse, 50 ; Check every 50ms
 
Sub_ClickMouse:
    if (SubStr(A_Now,9) != "193416")
	return
   Sleep, 978
   Click
Return


montyburly
  • Members
  • 5 posts
  • Last active: May 24 2015 07:55 AM
  • Joined: 12 May 2015

.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

How do you notice Timer being 100ms off?



montyburly
  • Members
  • 5 posts
  • Last active: May 24 2015 07:55 AM
  • Joined: 12 May 2015

.



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

If your using that link you would have to account for your internet latency.



montyburly
  • Members
  • 5 posts
  • Last active: May 24 2015 07:55 AM
  • Joined: 12 May 2015

If your using that link you would have to account for your internet latency.

Is there another way of testing it?



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013
✓  Best Answer

I get 5ms with A_Tickcount.

#Persistent
SetBatchLines -1
SendMode, Input

SetTimer, Sub_ClickMouse, 20 ; Check every 20ms


Sub_ClickMouse:  
    t:=A_TickCount
    ; Check if it's 17:00:00, or 5PM

    if (A_Hour = 19) ; Hour in 24h time
 
    and (A_Min = 34)
 
    and (A_Sec = 16) {
 
       Sleep, 978
 
       Click
       
       ToolTip % A_TickCount-t-978
    }
return

You could also use QueryPerformanceCounter for more accuracy if needed.

 

Note : Fixed Typo.


Edited by Xtra, 16 May 2015 - 12:53 AM.


montyburly
  • Members
  • 5 posts
  • Last active: May 24 2015 07:55 AM
  • Joined: 12 May 2015

.



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008

Should be SetTimer, Sub_ClickMouse1, 20 ; Check every 20ms



Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Sorry for the typo i was testing the speed of 3-4 different ways to do your script.

 

Remove the 1 in Sub_ClickMouse1 label or add a 1 to the settimer.