Debugging in VSCode

Scripting and setups with Visual Studio Code (vscode) and AutoHotkey.
Sundog
Posts: 4
Joined: 14 Feb 2024, 20:34

Debugging in VSCode

14 Feb 2024, 20:41

I have a simple AHK v2 script that controls another application via key presses. Example:

Code: Select all

Send "A"
Send "{Tab}{Tab}"
Send " "
Send "B"
I have VSCode installed and the debugger seems to be working, but when I add a breakpoint, it focuses my script in VSCode and applies the command to that script (IE it adds the letter A to line one of the script, 2 tabs to line 2 of the script, etc.). Is there a way to keep the application I want to control (eg a blank notepad) in focus while allowing me to step through the code?


[Mod edit: Moved from 'Ask for Help (v2)' since question is editor-related.]
User avatar
boiler
Posts: 17706
Joined: 21 Dec 2014, 02:44

Re: Debugging in VSCode

14 Feb 2024, 21:41

This is why I don’t use a debugger for a lot of my AHK coding because it often interacts with other windows. There are other ways to leave a popcorn trail of what is getting executed and when, such as inserting ToolTip, MsgBox (focus usually returns to the window that had it when it is dismissed or times out), and SoundBeep calls into key points of your code.
Sundog
Posts: 4
Joined: 14 Feb 2024, 20:34

Re: Debugging in VSCode

21 Feb 2024, 20:08

Thanks! I've done a lot with Tooltips and Message boxes, but I was hoping for a more streamlined way. I will play around with your other suggestions.
User avatar
thqby
Posts: 560
Joined: 16 Apr 2021, 11:18
Contact:

Re: Debugging in VSCode

21 Feb 2024, 23:07

You can also use OutputDebug or debugger instructions.

Code: Select all

var := 'msg'
;@Debug-Output => {var}
jsong55
Posts: 321
Joined: 30 Mar 2021, 22:02

Re: Debugging in VSCode

10 Mar 2024, 03:20

@thqby
jsong55 wrote:
09 Mar 2024, 21:38
Any native AHK capability can do this?

How to Console.WriteLine to the VSCode console?
Got ideas?
User avatar
thqby
Posts: 560
Joined: 16 Apr 2021, 11:18
Contact:

Re: Debugging in VSCode

10 Mar 2024, 05:59

Code: Select all

OutputDebug(str '`n')
FileAppend(str '`n', '*')
jsong55
Posts: 321
Joined: 30 Mar 2021, 22:02

Re: Debugging in VSCode

10 Mar 2024, 19:04

Without going into debug?
User avatar
thqby
Posts: 560
Joined: 16 Apr 2021, 11:18
Contact:

Re: Debugging in VSCode

11 Mar 2024, 11:32

Using OutputDebug in debugging.
Output to stdout FileAppend(str '`n', '*') at any time.
wilkster
Posts: 19
Joined: 15 Jul 2020, 09:43

Re: Debugging in VSCode

11 Mar 2024, 11:46

I use https://github.com/CobaltFusion/DebugViewPP to capture OutputDebug messages.
jsong55
Posts: 321
Joined: 30 Mar 2021, 22:02

Re: Debugging in VSCode

12 Mar 2024, 11:25

@thqby THANKS! :D :D :bravo: :bravo: awesome as usual it worked.

Return to “Visual Studio Code”

Who is online

Users browsing this forum: No registered users and 9 guests