How to tell which line is executing without using msgbox?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

How to tell which line is executing without using msgbox?

Post by milkygirl90 » 16 Jun 2021, 19:11

Sometimes when changing the sequence of my few thousand liner script, the hotkeys go wonky and I have to ctrl+F to find the most possible Combination that has a bug. Does AHK have a tool to let me know which line it is executing when i hit the hotkey in a context sensitive environment ?

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 16 Jun 2021, 23:10

Using ToolTip works better than MsgBox for real-time tracking of the flow of the script because it doesn’t interrupt the execution or change other context aspects, such as the active window.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to tell which line is executing without using msgbox?

Post by milkygirl90 » 17 Jun 2021, 00:28

boiler wrote:
16 Jun 2021, 23:10
Using ToolTip works better than MsgBox for real-time tracking of the flow of the script because it doesn’t interrupt the execution or change other context aspects, such as the active window.
yeah but I don't wanna insert a tooltip/msgbox in every part of my master script. Is there an alternative?

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 17 Jun 2021, 04:16

You may know this already, but you can double-click on the script’s icon in the system tray to view the most recently executed lines.


User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to tell which line is executing without using msgbox?

Post by milkygirl90 » 18 Jun 2021, 20:46

boiler wrote:
17 Jun 2021, 04:16
You may know this already, but you can double-click on the script’s icon in the system tray to view the most recently executed lines.
For instance, I have this line in both scripts that are active and running:

Code: Select all

ScrollLock::reload
However only 1 script reloads. The most recent executed lines does not show the line being executed. How do I debug this then?

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 18 Jun 2021, 21:37

milkygirl90 wrote: For instance, I have this line in both scripts that are active and running:

Code: Select all

ScrollLock::reload
However only 1 script reloads. The most recent executed lines does not show the line being executed. How do I debug this then?
Only one script actually executed that line, so no tracking of lines being executed will help point you to the issue. The issue is that when one script intercepts the press of the ScrollLock key, that keypress is no longer available for the other script to act on. You need at least one script to not "eat" that key but to allow it to pass through as it acts on it (i.e., to allow it to retain its native function). That will allow the other script to see it and have its hotkey triggered. Try changing that line in one of the scripts to this:

Code: Select all

~ScrollLock::reload

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to tell which line is executing without using msgbox?

Post by milkygirl90 » 18 Jun 2021, 21:59

boiler wrote:
18 Jun 2021, 21:37
milkygirl90 wrote: For instance, I have this line in both scripts that are active and running:

Code: Select all

ScrollLock::reload
However only 1 script reloads. The most recent executed lines does not show the line being executed. How do I debug this then?
Only one script actually executed that line, so no tracking of lines being executed will help point you to the issue. The issue is that when one script intercepts the press of the ScrollLock key, that keypress is no longer available for the other script to act on. You need at least one script to not "eat" that key but to allow it to pass through as it acts on it (i.e., to allow it to retain its native function). That will allow the other script to see it and have its hotkey triggered. Try changing that line in one of the scripts to this:

Code: Select all

~ScrollLock::reload
Now only the script with the ~ reloads.

Funny thing is, when I have this code, it reloads both scripts (but I also want it to work outside of notepad):

Code: Select all

#If WinActive("ahk_class Notepad++") ; Auto reload script upon saving it
~^s::reload
return

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 18 Jun 2021, 22:12

I doubt it has to do with the #If directive. It probably has more to do with the choice of hotkey. Try using a different hotkey than ScrollLock, at least for a test. I get the same hotkey to work in two different scripts simultaneously with that approach in my testing.

You could also try leaving it with ScrollLock but add ~ to both scripts. That might mean that your actual ScrollLock toggle state will change when you press the hotkey, which may or may not be an issue for you.

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to tell which line is executing without using msgbox?

Post by milkygirl90 » 20 Jun 2021, 07:53

boiler wrote:
18 Jun 2021, 22:12
I doubt it has to do with the #If directive. It probably has more to do with the choice of hotkey. Try using a different hotkey than ScrollLock, at least for a test. I get the same hotkey to work in two different scripts simultaneously with that approach in my testing.

You could also try leaving it with ScrollLock but add ~ to both scripts. That might mean that your actual ScrollLock toggle state will change when you press the hotkey, which may or may not be an issue for you.
I noticed if I add ~ to both scripts, I can't use the following lines below for both scripts either:

Code: Select all

^Scrolllock::Suspend
Is there any way I can still use modifiers with scrolllock for all the other functions - suspend, edit, reload?

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 20 Jun 2021, 07:57

Did you try adding ~ before those hotkeys as well?

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: How to tell which line is executing without using msgbox?

Post by milkygirl90 » 20 Jun 2021, 08:01

boiler wrote:
20 Jun 2021, 07:57
Did you try adding ~ before those hotkeys as well?
yup, totally did not work at all with modifiers.

User avatar
boiler
Posts: 16709
Joined: 21 Dec 2014, 02:44

Re: How to tell which line is executing without using msgbox?

Post by boiler » 20 Jun 2021, 08:22

It might again be a quirk relative to your choice of hotkey.

Post Reply

Return to “Ask for Help (v1)”