I am using Visual Studio Code as code editor for my AutoHotkey development. I was looking for an easy way to open the AHK documentation about a selected command from the editor. Here is my final solution.
Unfortunately, I couldn't find such a built-in feature in a VSCode extension for AHK.
I personally use now Mark Wiemer AutoHotkey Plus Plus extension. (It looks like the most maintained extension)
I have made a feature request here: https://github.com/mark-wiemer/vscode-autohotkey-plus-plus/issues/78
fade2gray posted his solution that is based on (...) a AutoHotkey script.
This is a bit more robust than the solution by fade2gray (it will only get once in the script runtime the snippets):
#If (WinActive("ahk_exe Code - Insiders.exe") || WinActive("ahk_exe Code.exe")) && WinActive(".ahk")
!h:: ; Alt+h AHK Open Help command
cmd:= Clip_GetSelection()
If !cmd
return
If !snippets {
; Make sure command has been copied to the clipboard and run this script
If WinActive("ahk_exe Code - Insiders.exe")
sVSDir := "C:\Users\" A_UserName "\.vscode-insiders"
Else
sVSDir := "C:\Users\" A_UserName "\.vscode"
Loop, Files,% sVSDir "\extensions\*", D
If InStr(A_LoopFilePath, "mark-wiemer.vscode-autohotkey-plus-plus"){
ahkjsonFile := A_LoopFilePath "\snippets\ahk.json"
Break
}
FileRead, snippets, %ahkjsonFile%
}
If !ahkjsonFile and !InStr(snippets, cmd){
MsgBox, Invalid command '%cmd%'.
return
}
Run,% "https://www.autohotkey.com/docs/commands/" cmd ".htm"
Return
To use it select the command and run the hotkey (in my case alt+h)
No comments:
Post a Comment