Call a hotkey by pressing a key within a hotkey

Get help with using AutoHotkey and its commands and hotkeys
Nixcalo
Posts: 26
Joined: 06 Feb 2018, 04:24

Call a hotkey by pressing a key within a hotkey

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.

Code: Select all

#o::
Var2=1
x = 1
while x<=10
{
Do something
Var2++
Do something else
Var2++
Do something different
Var2++
x++
}
Return
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! :(
User avatar
Xtra
Posts: 1515
Joined: 02 Oct 2015, 12:15

Re: Call a hotkey by pressing a key within a hotkey

19 Feb 2018, 22:12

ListVars etc. Can be accessed by double clicking the green ahk icon in system tray.

Also see: debugging a script

HTH
User avatar
Xtra
Posts: 1515
Joined: 02 Oct 2015, 12:15

Re: Call a hotkey by pressing a key within a hotkey

19 Feb 2018, 22:22

Simple examples of displaying a vars content:

Press 1 and then press 2 close message box press 2 again etc.

Code: Select all

#NoEnv

1::
    Loop
    {
        var++
        Sleep 1000
    }
return

2::MsgBox % var
3::ExitApp
or

Code: Select all

#NoEnv

1::
    Loop
    {
        var++
        Sleep 1000
    }
2::MsgBox % var
return

3::ExitApp
Nixcalo
Posts: 26
Joined: 06 Feb 2018, 04:24

Re: Call a hotkey by pressing a key within a hotkey

19 Feb 2018, 22:56

I don't know if I have been understaood correctly. I need to be able to insert that code WITHIN a long hotkey so ANYTIME I press that second hotkey, a MsgBox pops up with the data I need. Xtra, would those scripts you have written allow me to process normally a script and then interrupt them at any time to pop up a MsgBox the second I press a particular hotkey? Do you think you could insert that script in my code and it would work? Can't do it right now, will test it later, but I don't really see how...

Regarding the double click thing, I discovered that a little after posting, and it's useful, although not exactly what I am looking for... but better than nothing! But still leaves my question unresolved.
User avatar
Xtra
Posts: 1515
Joined: 02 Oct 2015, 12:15

Re: Call a hotkey by pressing a key within a hotkey

20 Feb 2018, 00:14

Post your script and the line number where there is this waiting for return problem.

Return to “Ask For Help”

Who is online

Users browsing this forum: agrout, Bing [Bot], Google [Bot], JoeWinograd, maxkill, Odlanir, Schezza, Sizion, teadrinker and 83 guests