Call a hotkey by pressing a key within a hotkey
Posted: 19 Feb 2018, 20:33
Hi All!
I have this following problem. I have a script that has got more and more complicated with time. It's giving me weird problems, so I have tried to debug it. Particularly, I want to know when the script stops waiting for something to happen when it shouldn't (as in waiting for a particular key input or a ClipWait command, etc.). The script basically consists of a hotkey "#o" that does several things.
The autohotkey program itself does not show the information I want (it seems the script is waiting infinitely and the only thing that appears is that it's apparently waiting in a Return command. The point is, I have NO idea where the script is stuck or why.
So I have had the following idea. I have inserted a variable %Var2% starting as 1, and then I increment that variable Var2++ each time I do a complicated thing.
I want to be able to recall the contents of that variable (a MsgBox, %Var2% command) with the press of a hotkey so I can find ANYTIME, even if the script is stuck, the value of that variable. That way I can more or less locate where the script is stuck.
How can I do it? I have no idea, setting a ^p::MsgBox, %Var2% does NOT work. Funnily, when I place this within my own script, if I place it OUTSIDE THE TRIGGERING HOTKEY #o, it does not have access to %Var2% (which is defined in my main hotkey. But if I place it within my main hotkey, it is just executed without waiting for any key press.
I have though I'd rather place the simplified code.
So basically I want to be able to know the value of Var2 with the press of a key so I know from it's output whether they script stuck in Do something, Do something else or Do something different.
Damn, it must be easy but I haven't found how in the forums!
I have this following problem. I have a script that has got more and more complicated with time. It's giving me weird problems, so I have tried to debug it. Particularly, I want to know when the script stops waiting for something to happen when it shouldn't (as in waiting for a particular key input or a ClipWait command, etc.). The script basically consists of a hotkey "#o" that does several things.
The autohotkey program itself does not show the information I want (it seems the script is waiting infinitely and the only thing that appears is that it's apparently waiting in a Return command. The point is, I have NO idea where the script is stuck or why.
So I have had the following idea. I have inserted a variable %Var2% starting as 1, and then I increment that variable Var2++ each time I do a complicated thing.
I want to be able to recall the contents of that variable (a MsgBox, %Var2% command) with the press of a hotkey so I can find ANYTIME, even if the script is stuck, the value of that variable. That way I can more or less locate where the script is stuck.
How can I do it? I have no idea, setting a ^p::MsgBox, %Var2% does NOT work. Funnily, when I place this within my own script, if I place it OUTSIDE THE TRIGGERING HOTKEY #o, it does not have access to %Var2% (which is defined in my main hotkey. But if I place it within my main hotkey, it is just executed without waiting for any key press.
I have though I'd rather place the simplified code.
Code: Select all
#o::
Var2=1
x = 1
while x<=10
{
Do something
Var2++
Do something else
Var2++
Do something different
Var2++
x++
}
Return
Damn, it must be easy but I haven't found how in the forums!