I am creating a simple repeat keystroke loop that is supposed to break on pressing ^F2. I have tried debugging but am unable to. I do get the prompt when I press ^F2, indicating that it was registered. In another debugging attempt, it seems like the global variable "checkbit" is not being changed. Any idea why? I am not familiar with how AHK variables work...
global checkbit := 0
^F1::{
checkbit := 0
Loop{
Send "{Enter}"
Sleep 1000
if checkbit = 1{
msgbox "exiting loop"
break
}
}
return
}
^F2::{
msgbox "exiting"
checkbit := 1
return
}
I tried more debugging and found out that the variables inside my ^F1 function are local and does not read the global variable. How do I resolve this? I've seen other similar threads that apparently works but I replicated those and failed
Upon further research, I have found a useful thread about writing global variables... https://www.autohotkey.com/boards/viewtopic.php?t=112514
so we gotta declare "global" within the function to write the global variable. This works now!