As a lot of V2 users use VS code, It would be very helpfull if the Edit button on the Warning message would check if code.exe is open to do an action to go to the line of the error.
In vs code, you can go to the line by:
Sendinput("^p")
Sendinput( filepath ":" linenumber "{Enter}")
Improde ahk error window
Re: Improde ahk error window
Correction, this is cleaner:
Run(A_ComSpec ' /c "Code --goto "' filepath ':' linenumber '"" ',,"Hide")
Run(A_ComSpec ' /c "Code --goto "' filepath ':' linenumber '"" ',,"Hide")
Re: Improde ahk error window
The edit button executes the "edit" verb. You can modify its effect in the registry. see this post with notes on such a change plus a script to jump to the error line in Notepad++.
viewtopic.php?p=490440#p490440
You can customize it to use VS Code instead.
viewtopic.php?p=490440#p490440
You can customize it to use VS Code instead.
Re: Improde ahk error window
@neogna2 Thanks for the tip, this was exactly what I was looking for.neogna2 wrote: ↑02 Apr 2023, 06:39The edit button executes the "edit" verb. You can modify its effect in the registry. see this post with notes on such a change plus a script to jump to the error line in Notepad++.
viewtopic.php?p=490440#p490440
You can customize it to use VS Code instead.
Here is the version that works for VS code, in the comments is mentioned how to set the registry.
This is cool, even when you not run in debug mode, it is easy to jump to the file on the correct line.
I modified it a little bit so that it also keeps the normal Edit function.
Code: Select all
#SingleInstance Force
#Requires AutoHotkey v2.0
; Modify the registry:
; Computer\HKEY_CLASSES_ROOT\AutoHotkeyScript\shell\edit\command "<AutohotkeyDirectory>\AutoHotkey32.exe" "<DirectoryErrorEditVSC>\ErrorEditVSC.ahk" "%1"
; RegWrite Format('"{1}" "{2}" "%1"', A_AhkPath, A_ScriptFullPath), "REG_SZ", "HKCR\AutoHotkeyScript\Shell\Edit\Command"
if A_Args.Has(1)
{
ScriptFile := A_Args[1]
SplitPath(ScriptFile, &Filename)
ErrorHwnd := WinExist(Filename " ahk_class #32770")
Try CtlText := ControlGetText("RichEdit20W1", "ahk_id " ErrorHwnd)
if IsSet(CtlText){
if RegExMatch(CtlText, "\R▶\t(\d+):", &oMatch) or RegExMatch(CtlText, "\RLine:\t(\d+)\R", &oMatch)
{
Line := LTrim(oMatch.1, "0")
;edit next line with preferred text editor path and cli goto line syntax
; Run('notepad++.exe "' ScriptFile '" -n' Line)
Run(A_ComSpec ' /c "Code --goto "' ScriptFile ':' Line '"" ',,"Hide")
ExitApp
}
}
Run( '"' StrReplace(A_AppData,"Roaming","") 'Local\Programs\Microsoft VS Code\Code.exe" ' '"' ScriptFile '"')
ExitApp
}
Run( '"' StrReplace(A_AppData,"Roaming","") 'Local\Programs\Microsoft VS Code\Code.exe"')
ExitApp