Visual Studio Code Support

Discuss features, issues, about Editors for AHK
haichen
Posts: 137
Joined: 09 Feb 2014, 08:24

Visual Studio Code Support

31 Dec 2015, 07:13

After the nice work with Atom, i thought it would be also nice to run AutoHotkey from Visual Studio Code. I found an extension for syntax highlighting and here is how i got it working:

In VSC type
1. strg+p
2. ?
3. klick ext install
4. type autohotkey

klick on install

After restart of VSC it says there is an issue with this extension.
But nevertheless i could get it working by downloading the extension from
https://github.com/stef-levesque/vscode ... master.zip
Then i copied the files in the zip in the VSC extension dir:
C:\Users\user\.vscode\extensions\slevesque.vscode-autohotkey-0.0.1
After a restart i got the syntaxhiglighting.

At second i wanted to run a script from VSC. After searching i tried the extension "Runner" from
Yasuhiro Matsumoto

As above type
1. STRG+P
2. ?
3. klick ext install
4. type runner

klick on install

After this you have to open the menu File>Preferences>User Settings.
This menu shows the Default Settings at the left and the file settings.json at the right where you have to copy

Code: [Select all] [Download] GeSHi © Codebox Plus

{
"runner.languageMap": {"autohotkey": "C:/Program Files/AutoHotkey/autohotkey.exe"},
"runner.extensionMap": {"ahk": "autohotkey"},
}


After saving try to run (STRG+SHIFT+R) a test.ahk with



You get the text in an ouput column in VSC.
Zeb

Re: Visual Studio Code Support

28 Sep 2016, 05:40

Even tho this Post is probably too old to hope for a reply but I can't get it to execute my scripts. It says "autohotkey" was either wrong written or couldn't be found.
haichen
Posts: 137
Joined: 09 Feb 2014, 08:24

Re: Visual Studio Code Support

30 Sep 2016, 02:51

I saw it yesterday. Meanwhile I've a new pc. So I had to to install VSC and try my own Tip. But it also didn't work for me and until now I found no solution. Sorry!
Zeb

Re: Visual Studio Code Support

25 Oct 2016, 08:54

Well after checking the source-code of the extension and not finding anything suspicious... I simply tried out the fullpath for the autohotkey.exe plus double-double-quotes, which does the job.
Seems kind-of stupid but I don't care as long as it works that way.

Code: [Select all] [Download] GeSHi © Codebox Plus

{
"runner.languageMap": {"autohotkey": "C:/Program Files/AutoHotkey/autohotkey.exe"},
"runner.extensionMap": {"ahk": ""C:/Program Files/AutoHotkey/autohotkey.exe""},
}
haichen
Posts: 137
Joined: 09 Feb 2014, 08:24

Re: Visual Studio Code Support

25 Oct 2016, 11:59

oh wow, very strange! Thank you very much for finding this!!
momo2000
Posts: 32
Joined: 25 Jan 2015, 12:00

Re: Visual Studio Code Support

11 Nov 2016, 08:44

Trying to get VSC working with AHK as well. Syntax highlighting works, but the Run/debug feature does not. I followed the steps above (and put those two lines in the settings.json file) but not working. When I got to run/debug, I get the error "Cannot find runtime 'node' on PATH." Any ideas?
mh1723
Posts: 1
Joined: 08 Jan 2017, 21:47

Re: Visual Studio Code Support

08 Jan 2017, 22:03

I am very new to all this but very interested in also setting it up. Every time I have come across a not found in PATH type issue it stems from not having one file or another properly set in the system environmental variables. From the System window or right click start button->system->advanced system settings->Environment Variables. Include the paths for everything AHK related.

At times I have had to go down a few levels in a directory and select another folder in order for it to pick it up correctly.
haichen
Posts: 137
Joined: 09 Feb 2014, 08:24

Re: Visual Studio Code Support

10 Feb 2017, 08:35

I tried another try to get "runner" to run but failed.

So i now try another "Code Runner". This Extension works and so want to share it with you.

https://marketplace.visualstudio.com/it ... ode-runner

Installation:
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install code-runner

After Installation you have to add the following to the menu File>Preferences>User Settings
(You may leave or change all other "executors" from the example but i take here only autohotkey related):

Code: [Select all] [Download] GeSHi © Codebox Plus

{
"code-runner.executorMap": {
"autohotkey": "\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\"",
},
"code-runner.defaultLanguage": "autohotkey",
"code-runner.executorMapByFileExtension": {
".ahk": "\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\""
}
}


Right click - "Run Code" and autohotkey runs the whole script or the marked text.
Stenemo
Posts: 4
Joined: 25 Dec 2015, 04:48
Facebook: Stenemo
GitHub: MarkusStenemo

Re: Visual Studio Code Support

23 Apr 2017, 05:53

Are there any ongoing projects to make this available for Visual Studio 2017 as well?
User avatar
J Scott Elblein
Posts: 7
Joined: 21 Aug 2017, 05:19
GitHub: STaRDoGG
Location: Chicago
Contact:

Re: Visual Studio Code Support

01 Sep 2017, 23:08

Not exactly sure what I'm missing here; seems like it should work but, I still get the error, when trying to run a script:

[Running] autohotkey "g:\FileMenuTools\App\FileMenu Tools\My Custom Additions\Coding\Scripting\AutoHotKey\My Scripts\tempCodeRunnerFile.ahk"
'autohotkey' is not recognized as an internal or external command,
operable program or batch file.


I have Code Runner installed, and I opened the settings file, and added this exactly:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



NOTE: I commented out the .defaultlanguage line because I don't want to set CR to use AHK as the default language (still new to both VSCode, and AHK, and also CR, so maybe I'm misunderstanding that line?), but either way, even when I don't comment that line out, I still get the same error.

I also restart VSCode between each change, just to be sure it "took".

Anyone able to point out the problem?

Update:

Scratch that; not exactly sure why, since reloading the entire app didn't allow it to work, but after adding another extension, and then pressing the "reload" button for that extension after it was installed, somehow got ahk to work in CR. :facepalm:
icuurd12b42
Posts: 121
Joined: 14 Aug 2016, 04:08

Re: Visual Studio Code Support

08 Sep 2017, 18:03

I got the Highlighting working. As for the runner bit and how to run a ahk file from the IDE I got no clue

and psst: https://autohotkey.com/boards/viewtopic ... 26#p169526
haichen
Posts: 137
Joined: 09 Feb 2014, 08:24

Re: Visual Studio Code Support

09 Sep 2017, 05:07

Mostly I use SciTE4AutoHotkey or Notepad2 but occasionally I try Visual Studio Code.
Now I found how to get Code-Runner working again. The difference to my settings above (which worked some time) is changing autohotkey to ahk in the .executorMap.

This works for me:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Intellisense works for autohotkey! Nice.
User avatar
J Scott Elblein
Posts: 7
Joined: 21 Aug 2017, 05:19
GitHub: STaRDoGG
Location: Chicago
Contact:

Re: Visual Studio Code Support

07 Oct 2017, 10:22

Seems everything works great so far; intellisense, syntax highlighting, and running the code with code runner. Only problem left (for me at least) is actually being able to set breakpoints, and debug as you would line by line, (etc.).

Anyone else have the same problem?
User avatar
boiler
Posts: 1989
Joined: 21 Dec 2014, 02:44

Re: Visual Studio Code Support

18 Oct 2017, 14:45

haichen wrote:Now I found how to get Code-Runner working again. The difference to my settings above (which worked some time) is changing autohotkey to ahk in the .executorMap.
Thanks for this. I was frustrated with why the previous settings weren't working for me, but it works now. This along with the other features mentioned above (as well as GotoTilla, mentioned below) make it a pretty nice AHK editor. I'm liking it.

J Scott Elblein wrote:Seems everything works great so far; intellisense, syntax highlighting, and running the code with code runner. Only problem left (for me at least) is actually being able to set breakpoints, and debug as you would line by line, (etc.).

Anyone else have the same problem?
I didn't think any debugging extensions have been implemented for AHK yet. Am I wrong about that?

By the way, GoToTilla, a tool for jumping directly to your functions, labels, hotkeys, and hotstrings (similar to TillaGoto in SciTE4AutoHotkey) works great in Visual Studio Code. Use the update by hoppfrosch at the bottom of the linked page.
User avatar
J Scott Elblein
Posts: 7
Joined: 21 Aug 2017, 05:19
GitHub: STaRDoGG
Location: Chicago
Contact:

Re: Visual Studio Code Support

12 Nov 2017, 16:18

I didn't think any debugging extensions have been implemented for AHK yet. Am I wrong about that?

Looks that way, unfortunately. I'm pretty surprised actually. Seems like AHK is popular enough that someone would've felt the need for breakpoints, reading live vars, etc., and already made a vscode extension to debug ahk scripts. :wtf:

After reading the AHK help, it looks like this would work in vscode, but, I just don't have the time to implement it myself. Hopefully someone with some time would take the initiative. *praying emoticon*

Return to “Editors”

Who is online

Users browsing this forum: No registered users and 2 guests