Jump to content

Problem with timer function


peanutym
 Share

Recommended Posts

So i have a function that i call every few seconds. it checks the timer and pushes a key whenever the timer is up. Below is the code for the function and the timer that i want to use. By themselves the program will push the key when the timer is ready. Weither i use buff1 or buff2 seperatly. But my issue is that when i want them both to count down then only the 2nd one works. No matter what the timer is set to for either of them.

Any help is appreicated. The only difference in the 2 is that each section is using either b1 or b2 as their timer variable. rest of it is the same. i actually have 4 sections of these that i will want to work, but for now i thought getting 2 of them would be helpful.

;Buff1
If guictrlread($b1_enteredkey) <> "" Then ;if something is actually entered then...
If TimerDiff($timerb1)/1000 >= GUICtrlRead($b1_enteredtime) Then ;check if the time past on the timer is > or = to the entered time
send ("{"&Guictrlread($upkey)& ' up'&"}")
$firstlettercheck=StringLeft(guictrlread($b1_enteredkey),1) ;get variable of the first letter of the entered key
If $firstlettercheck = "!" or $firstlettercheck = "^" or $firstlettercheck = "+" Then ;if it is an Alt/Shift/Control modifier in front then
Send(GUICtrlRead($b1_enteredkey))   ;send keys raw
Else 
Send("{" & GUICtrlRead($b1_enteredkey)& "}") ;send keys static
Endif
Sleep(300)
$timerb1 = TimerInit() ;restart the timer
Sleep(skillcasttime()+3000) ;sleep for the duration of the cast(if any)
EndIf
Endif

;Buff2
If guictrlread($b2_enteredkey) <> "" Then
If TimerDiff($timerb2)/1000 >= GUICtrlRead($b2_enteredtime) Then
send ("{"&Guictrlread($upkey)& ' up'&"}")
$firstlettercheck=StringLeft(guictrlread($b2_enteredkey),1)
If $firstlettercheck = "!" or $firstlettercheck = "^" or $firstlettercheck = "+" Then
Send(GUICtrlRead($b2_enteredkey))
Else 
Send("{" & GUICtrlRead($b2_enteredkey)& "}")
Endif
Sleep(300)
$timerb2 = TimerInit()
Sleep(skillcasttime()+3000)
EndIf
EndIf
Link to comment
Share on other sites

I think you need to show us a script we can run which shows the problem for us to see how those lines are used and understand the problem.

Meanwhile, might the sleeps in those If cases make it difficult to check the other timer soon enough?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...