launch.json runtime config ignored
Type: Bug
• Install AHK v1 after installing AHK v2 first • Open a v1 script. • Click on Debug AHK file.
Result
You get an error about runtime path not existing even if you set the launch.json configuration and extension configurations to point to the correct location.
Extension version: 6.5.0 VS Code version: Code 1.98.2 (ddc367ed5c8936efe395cffeec279b04ffd7db78, 2025-03-12T13:32:45.399Z) OS version: Windows_NT x64 10.0.26100 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 12th Gen Intel(R) Core(TM) i7-12700KF (20 x 3610) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | undefined |
| Memory (System) | 31.84GB (19.93GB free) |
| Process Argv | --crash-reporter-id 3e042e59-cb22-4371-968a-6f3e35abe666 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
9064b325:31222308
copilot_t_ci:31222730
f27dg485:31264363
968h8231:31277804
jda6j935:31233686
pythoneinst12cf:31262606
bgtreat:31268568
fh1c7952:31258891
4gafe986:31271826
31787653:31262186
3e8i5726:31271747
49da9784:31264548
usemplatestapi:31277718
Not sure why adjusting the paths isn't working for you In my experience, this happens when installing AutoHotkey and v2 is installed before v1. You can get around it by copying all files from the v1.1.37.02 folder into the AutoHotkey folder, then delete the v1.1.37.02 folder and adjust the paths accordingly.
From what I understand, AutoHotkey permits multiple installations of older v1 versions, hence the specific version folder
Observations: In AHK++ settings, you have AutoHotkeyU32.exe In launch.json, you have AutoHotkeyU64.exe The error dialogue is looking for AutoHotkey.exe
@RaptorX have you tried setting "type": "ahk" instead of "autohotkey"? Ref https://github.com/mark-wiemer/ahkpp/blob/main/demos/.vscode/launch.json
@RaptorX have you tried setting
"type": "ahk"instead of"autohotkey"? Ref https://github.com/mark-wiemer/ahkpp/blob/main/demos/.vscode/launch.json
yes.
there was a notification that said that ahk is deprecated and that I should use autohotkey instead.
I am still getting the same error though. And also I cannot specify the runtime or runtime_v1 properties. So no go.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "ahk",
"request": "launch",
"name": "AutoHotkey v1 Debugger",
"program": "${file}",
"stopOnEntry": true
}
]
}
Thanks for the update. I'll look into this, sorry for the inconvenience.
I can testify that this issue still exists when run v1 script, which starts with #Requires AutoHotkey v1.1. The problem is caused by zero-plusplus‘s vscode-autohotkey-debug plugin, which has higher priority than "ahkpp" when debug v1 script.
------The only thing you need to do is disable or remove vscode-autohotkey-debug plugin.-----
The reason why we still need vscode-autohotkey-debug plugin even though there is ahkpp installed, is that the Debug AHK with Params button provided by ahkpp depends with vscode-autohotkey-debug.
Below v1 script copied from chatgpt aims to test the Debug AHK with Params function supported by ahk+++, the inputs can be 5 4 3 or any other.
#----------------v1 with params----------------
#Requires AutoHotkey v1.1
; Check if at least one argument is passed
if (0 < 1) {
MsgBox, No arguments provided.
ExitApp
}
; Loop through all passed arguments
args := ""
Loop, %0% {
args .= "Arg" . A_Index . ": " . %A_Index% . "`n"
}
MsgBox, You passed the following arguments:`n`n%args%
#----------------v2 with params----------------
#Requires AutoHotkey v2.0
if A_Args.Length = 0 {
MsgBox "No arguments provided."
ExitApp
}
args := ""
for index, arg in A_Args {
args .= "Arg" index ": " arg "`n"
}
MsgBox "You passed the following arguments:`n`n" args
#----------------v1 vanilla----------------
#Requires AutoHotkey v1.1
; Hotkey: Ctrl+Alt+T shows a message box
^!t::
MsgBox, You pressed Ctrl+Alt+T!
return
; Hotstring: typing btw auto-replaces with "by the way"
::btw::by the way
; Hotkey: press F1 to open Notepad
F1::
Run, notepad.exe
return
; Hotkey: press Esc to exit the script
Esc::ExitApp
#----------------v2 vanilla----------------
#Requires AutoHotkey v2.0
; Hotkey: Ctrl+Alt+T shows a message box
^!t::MsgBox "You pressed Ctrl+Alt+T!"
; Hotstring: typing btw auto-replaces with "by the way"
::btw::by the way
; Hotkey: press F1 to open Notepad
F1::Run "notepad.exe"
; Hotkey: press Esc to exit the script
Esc::ExitApp()
ahkpp provides three builtin debug function -Run AHK Script Ctrl+F9 -Run Code -Debug AHK and Attach -Debug AHK Script Ctrl+Alt+F9 (only needs ahkpp) -Debug AHK with Params Ctrl+F5 (needs both ahkpp and vscode-autohotkey-debug) -Debug Configurations
New commands Debug AHK and Attach: Debug and attach to the debug session for advanced use-cases. Requires zero-plusplus.vscode-autohotkey-debug. Debug AHK with Params (Ctrl + F5): Debug and add user-provided command-line arguments to the debugger for advanced use-cases. Requires zero-plusplus.vscode-autohotkey-debug. From: Full AHK v2 support is here! https://github.com/mark-wiemer/ahkpp/pull/490
So, there is two situation with errors:
- Since Debug AHK Script Ctrl+Alt+F9 only needs ahkpp, when you install both plugin:
Debug AHK Scriptfailed with error:runtime must be a file path that exists. Specified:"C:\Program Files\AutoHotkey\AutoHotkey.exe" Open 'launch.json' Cancel, this error message is raised by vscode-autohotkey-debug. - Since Debug AHK with Params Ctrl+F5 needs both ahkpp and vscode-autohotkey-debug**, When you install only ahkpp (vscode-autohotkey-debug is disabled or uninstalled):
failed with error:
zero-plusplus.vscode-autohotkey-debug was not found! Source:AHK++(AutoHotkey Plus Plus)
---updated----- Currently,
-
if you only need
Debug AHK Scriptsfor v1 and v2, you only need to install ahkpp and configure your v1 and v2 interpreter path. -
if you also need
Debug AHK with params(not suggested),
Debug AHK with paramsis introduced by ahk2-lsp as commandahk++.debugParamsand depends with zero-plusplus.vscode-autohotkey-debug. Commandahk++.debugParamsuse ahk++'s v2 interpreter path (cannot be changed), but not runtime configured by zero-plusplus.vscode-autohotkey-debug (C:\Program Files\AutoHotkey\AutoHotkey.exe), soDebug AHK with paramsintroduced by ahk2-lsp only use v2/ahk.exe and only works for v2 script currently
2.1 for v2, you just need to install zero-plusplus.vscode-autohotkey-debug in addition.
https://github.com/mark-wiemer/ahk2-lsp/blob/565ab6a58b024e2657d65d30c7e1eb1f0b15c99c/util/src/env.ts#L92-L93
/** Debug with params */
export const extDebugParams = `${extCommandPrefix}debugParams`;
https://github.com/mark-wiemer/ahk2-lsp/blob/565ab6a58b024e2657d65d30c7e1eb1f0b15c99c/client/src/extension.ts#L474-L482
/**
* Begins debugging with the provided debug type.
* @param type 'f' for file, 'c' for configs, 'p' for params, 'a' for attach
* - f: Debug the current file.
* - c: Debug with the selected configuration.
* - p: Debug with the specified parameters. Only available for `zero-plusplus.vscode-autohotkey-debug`.
* - a: Attach to the process. Only available for `zero-plusplus.vscode-autohotkey-debug`.
*/
async function beginDebug(type: 'f' | 'c' | 'p' | 'a') {
2.2 for v1, Debug AHK with params is not supported yet, even if you installed both extensions.
2.2.1 Specially, if you if you installed both extensions, you may get below debug output log, which means Debug AHK with params function is binded with v2 interpreter (code given by ahk2-lsp), and cannot be changed:
"D:\PortablePrograms\scoopChoc\apps\autohotkey\current\v2\AutoHotkey64.exe" /Debug=127.0.0.1:9002 /ErrorStdOut C:\Users\Daibu\Desktop\New folder\x1.para.ahk1 4
C:\Users\Daibu\Desktop\New folder\x1.para.ahk1:1 : ==> This script requires AutoHotkey v1.0.
Current interpreter: AutoHotkey v2.0.19 64-bit
D:\PortablePrograms\scoopChoc\apps\autohotkey\current\v2\AutoHotkey64.exe
AutoHotkey closed for the following exit code: 2
Debugging stopped
2.2.2 Since you have install both extensions, which may interrupt Debug AHK Scripts's logic in the same time. Because zero-plusplus is prior to ahk++ for Debug AHK Scripts, so you need to change zero-plusplus's estension.ts file to configure your exact ahk.exe path as runtime attribute(zero-plusplus uses in its builtin launch.json), or you can just disable zero-plusplus temporarily to avoid conflicts in the situation.
https://github.com/mark-wiemer/ahkpp/blob/5d00d78b30f714bfb6ab3ab903f60954877a5cf2/src/service/runnerService.ts#L37-L53
https://github.com/zero-plusplus/vscode-autohotkey-debug/blob/c687a78eb27c2557a7d85e81a5263f0c2570a9df/src/extension.ts#L145-L153
defaults(config, {
name: 'AutoHotkey Debug',
type: 'autohotkey',
request: 'launch',
runtime_v1: 'AutoHotkey.exe',
runtime_v2: 'v2/AutoHotkey.exe',
hostname: 'localhost',
port: 9002,
program: config.request === 'launch'
Attention: Changing runtime attribution of package.json does not make sense, which is source code before TypeScript compile.
https://github.com/zero-plusplus/vscode-autohotkey-debug/blob/c687a78eb27c2557a7d85e81a5263f0c2570a9df/package.json#L208-L217
"runtime_v1": {
"type": "string",
"description": "This is the \"runtime\" when the extension is \".ahk\". If runtime is set, it takes precedence.",
"default": "AutoHotkey.exe"
},
"runtime_v2": {
"type": "string",
"description": "This is the \"runtime\" when the extension is \".ahk2\" or \".ah2\". If \"runtime\" is set, it takes precedence.",
"default": "v2/AutoHotkey.exe"
},