Another possible way to improve the timing would be through a custom routine to use the A_TickCount variable to
time the interval between swings. I use this method in many of my mmo game fight routines to get more
precise timing between one skill firing off and the next one. Since A_TickCount is a variable you can use it in your own variable to wait from the beginning or end of one event to the start of the next event similar to SetTimer or
Sleep. Here's a simple example that pops a second message box after the first is closed...
Code: Select all
; this produces the first message box that automatically shuts down after 3 seconds
MsgBox, 0x1000, Line%A_LineNumber% First Msgbox, This is the first message box, 3
; start the custom delay routine
reopenDelay := 3000 ;<- this is the time to wait for the second message box
reopen := (A_TickCount + reopenDelay) ;<- wait 3 seconds
while (A_TickCount < reopen)
{ ;do nothing
}
MsgBox, 0x1000, Line%A_LineNumber% Second Msgbox, This is the second message box, 3
exitapp
By changing the value of the reopen delay either manually or programmatically you can have variable sleeps in your routines or within the "do nothing loop you can have your script do other stuff unlike what
sleep does. Since
sleep basically shuts down your script unconditionally for a definite period of
time the A_TickCount loop like SetTimer lets you do other stuff until it times out. Of course, the more stuff you try to do inside the loop the more the loop timing will degrade.