B needs to run 1000ms after the most recent press of A (if B is pressed 100ms after A then B must first sleep 900ms). It should also run normally if no instance of A is detected in the last 1000ms of pressing B. How do I achieve this using AutoHotkey v2?
a_var:=false
a::{
global a_var
if a_var=false{
a_var:=true
setTimer a_timer, -1000
}
}
a_timer(){
global a_var:=false
}
b::{
global a_var
while a_var{
sleep 10 ;setTimer stops working, loop turns infinite
}
msgbox "success" ;needs to run 1000 ms after the most recent instance of a is pressed
}
setTimer
stops running once it enters the while loop.