VSCode doesn't like particular ahk file(?) Topic is solved

Scripting and setups with Visual Studio Code (vscode) and AutoHotkey.
User avatar
kunkel321
Posts: 1061
Joined: 30 Nov 2015, 21:19

VSCode doesn't like particular ahk file(?)

25 Mar 2024, 15:22

Has anyone else run into this? It's noteworthy that my ahk scripts are all set up as "portable" apps, with the ahk and the exe having the same name, in the same parent folder.

I use essentially this same setup for a different script in the same folder and it works fine. One particular ahk file won't open though. I don't get the 'Catch' message, it just doesn't open. If I use a different editor, it works. I tried doing a "save as" to make sure the ahk file is saved as v2. Also, the ahk file does open normally via double-clicking file, via 'Open' command in VSCode, and via JumpList. It just doesn't work with a Run command in a script (like below).

Strange....

Code: Select all

!+l::
EditThisLog(*)
{	soundBeep
   thisScript := StrReplace(A_ScriptFullPath, ".exe", ".ahk")
	Try
	   Run(MyAhkEditorPath " " thisScript)
	Catch
		msgbox 'cannot run ' thisScript
}
ste(phen|ve) kunkel
User avatar
RaptorX
Posts: 386
Joined: 06 Dec 2014, 14:27
Contact:

Re: VSCode doesn't like particular ahk file(?)  Topic is solved

26 Mar 2024, 08:07

What i am not really understading here is: the script launches itself?

Why dont you use the Reload command?

But back to the original question, if you are trying to run it from VSCode, open the debugging window. I have noticed that the v2 Extension many times catches the errors and display them in the debugging window instead of the normal dialog. It catches me offguard many times :lol:

Also always check the Problems section in VSCode and verify that the file is not reporting a simple problem and is not being launched because of that.
Projects:
AHK-ToolKit
User avatar
kunkel321
Posts: 1061
Joined: 30 Nov 2015, 21:19

Re: VSCode doesn't like particular ahk file(?)

26 Mar 2024, 11:44

Thanks RaptorX,

Actually, it occurred to me that it was an admin/non-admin problem--which should have been the first thing I checked. LOL. My AHK setup is such that double-clicking an ahk file opens it for editing. Using a normal Run command does the same. To 'launch' the script, I run the same-named exe file that is a renamed copy of AutoHotkey.exe, and is in the same folder as the ahk.

So when I want to reload/refresh the exe in RAM, I use Reload (or Run "script.exe") But when I want to open the script in my ahk editor, I use Run "script.ahk"

This setup does have disadvantages... For example when a new version of AutoHotkey.exe comes out, I don't have a way to systematically update all my exes. Another disadvantage is this above admin glitch.

If anyone reads this: The solution was to browse to my portable copy of AutoHotkey.exe (which is renamed to match the ahk), then right-click, choose 'Properties,' then the Compatibility tab, then check the "Run as administrator" checkbox.

Thanks for the tip on the Problems section of VSCode. I will check that out.

BTW your VSCode settings configuration thing
https://www.the-automator.com/downloads/vs-configure-tool/
has worked flawlessley -- Good stuff! v :thumbup:
ste(phen|ve) kunkel

Return to “Visual Studio Code”

Who is online

Users browsing this forum: No registered users and 74 guests