Is there any way to get around double setTimer or doubleLoop freezing up? Like when I go to duplicate the key in question to make another for a different key, the same thing keeps happening whether I'm using loops or setTimer.... one of the loops or timers will just freezup 'at some point' for at least one of its interations. I keep reading AHK mimics multithreading so....I try putting them in diffferent scripts and run those at the same time, but I always endup with the freezing up albeit with slightly differnt behaviours. I really have to press keys to get the issue in application settings, but in gaming it's really easy to mimick.
Say ingame if you press {f6} you cast an instant invulnerability state that lasts 5seconds. You can spam this after the 5seconds is done. It lasts 5s and it can only be recast once it is over. Holding the {f6} key ingame it 'sometimes' lets u spam it nonstop....its inconsistent especially when u start moving around and pressing other keys while holding it. So I write a script to make it more consistent. This script does the following:
>it binds f6 to the r key so its easier to press
>it allows the skill to be recast if u hold the key down for the entire 5s regardless of any movement inbetween.
>it allows any tap during the time the skill is active to automatically que up a second cast. I can either tap or tap-hold before the current 5s interval is over and the next 5s will automatically be cast....etc.
This all works fine, but say I have a second key I want to do the exact same thing for {f5} works the same and I want to bind it to "1". Well the moment I put both of these in the same script they might work for a while together in tandem...but eventually one of the timers will outright not proc for its 5s interval and basically be frozen for 5s before I can reproc it again. If I put each of these timers in their own script, one of the timers in whatever script is lower on the que WILL NOT WORK AT ALL....it'll be busted from the start. Ideally I want to get both timers working consistently, or at least not bugging completely for 5s where its frozen in the 'cant use the skill at all for 5s cause the key is bugged' state.
Code: Select all
+r::
r::{
static cat:=false
static cat_inf:=false
if not cat{
send "{f6}" ;sends skill_1 to be cast
cat:=true ;prevents spam outside interval, in 5030s it'll turn pressable again
setTimer timer5000, 5030
timer2000(){
cat:=false
if cat_inf{
send "r" ;resends the hotkey itself
cat_inf:=false
}
}
}
else if cat{
cat_inf:=true ;if I tap r again 'at any point' during timer2000 it will que and trigger another skillcast after the 5s is over
}
}
+1::
1::{
static cat:=false
static cat_inf:=false
if not cat{
send "{f5}" ;skill_2
cat:=true
setTimer timer5000, 5030
timer2000(){
cat:=false
if cat_inf{
send "1"
cat_inf:=false
}
}
}
else if cat{
cat_inf:=true
}
}