zero-plusplus / vscode-autohotkey-debug

https://marketplace.visualstudio.com/items?itemName=zero-plusplus.vscode-autohotkey-debug
53 stars 4 forks source link

[enhancement] Run script instead of debugging #13

Closed SAbboushi closed 4 years ago

SAbboushi commented 4 years ago

SciTE4AutoHotkey has Start Script button that I can press to run script without debugging. This is useful for me at times, such as when I am finished debugging a script and want to exit vscode but I want to leave the script running i.e. I don't want to exit vscode and then use alternate method to run the same script.

zero-plusplus commented 4 years ago

This is also the same as #5, so we will not implement it here.

Only the process related to the debugger is implemented. Basically, the accepted request is limited to the processing after pressing the debug button of SciTE4 AutoHotkey.

By the way, the feature you say will be implemented in a new project, so please wait for completion.

zero-plusplus commented 4 years ago

Look up formulahendry.code-runner and you might be happy.

You should be able to use it by adding the following settings.

settings.json
{
    ...
    "code-runner.executorMap": {
        "ahk": "\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" /r /errorStdOut",
        "ahk2": "\"C:\\Program Files\\AutoHotkey\\v2\\AutoHotkey.exe\" /r /errorStdOut",
    },
    //  You can also use it comfortably by adding the following settings.
    "code-runner.clearPreviousOutput": true,
    "code-runner.saveFileBeforeRun": true,
    ...
}
SAbboushi commented 4 years ago

Thank you for your kind response to provide the settings.

I have modified to:

"code-runner.executorMap": {
        "ahk": "\"J:\\StandaloneApps\\AutoHotkeyV2\\AutoHotkeyU64.exe\" /r /errorStdOut"
    }

I have been trying, but I keep getting

[Running] autohotkey "j:\Documents\Application Data\AutoHotkey\MasterAHKscriptElevated.ahk"
'autohotkey' is not recognized as an internal or external command,
operable program or batch file.

[Done] exited with code=1 in 0.034 seconds

I don't know where it gets string 'autohotkey' in error message. Also, "ahk" and "ahk2" in your settings: is this for file extension or for vscode language id author refers to (I could not find ahk/ahk2/autohotkey listed as language id on that page).

I tried setting for file extension but same error message:

"code-runner.executorMapByFileExtension": {
        "ahk": "\"J:\\StandaloneApps\\AutoHotkeyV2\\AutoHotkeyU64.exe\" /r /errorStdOut"
    }

I understand if you are too busy to help more since this is not your extension

zero-plusplus commented 4 years ago

You are trying to call the autohotkey registered on the global instead of the path you set. Like calling vscode with code, for example.

However, even if AutoHotkey is installed, it does not register the path globally. Therefore, AutoHotkey cannot be recognized and an error is displayed.

So, setting J:\StandaloneApps\AutoHotkeyV2 in the environment variable PATH would be a temporary solution.

If you set the executorMap, that setting should take precedence, but I'm not sure why it isn't. I have the latest version so it should probably be in the same state as you.

I will write down all the settings of my code-runner

settings.json
{
    "code-runner.clearPreviousOutput": true,
    "code-runner.enableAppInsights": false,
    "code-runner.executorMap": {
        "ahk": "\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" /r /errorStdOut",
        "ahk2": "\"C:\\Program Files\\AutoHotkey\\v2\\AutoHotkey.exe\" /r /errorStdOut",
    },
    "code-runner.saveFileBeforeRun": true,
}

Please try with the same settings as me once. Maybe it's because the drive is different.

By the way, I was able to execute without problems even with the following settings.

settings.json
{
    "code-runner.executorMapByGlob": {
        "*.ahk": "\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" /r /errorStdOut",
        "*.ahk2": "\"C:\\Program Files\\AutoHotkey\\v2\\AutoHotkey.exe\" /r /errorStdOut",
}
SAbboushi commented 4 years ago

Argh!! After a few hours I finally figured out: 1) code-runner uses "ahk" as default language id and uses "autohotkey" as default command. code-runner package.json:

"code-runner.executorMap": {
                    "type": "object",
                    "default": {
                    ...
                        "ahk": "autohotkey",

Even when disable language support extensions, code-runner still uses "autohotkey" as default command/executable when trying to launch .ahk script I think because of:

"code-runner.executorMapByFileExtension": {
                    "type": "object",
                    "default": {
                        ...
                        ".ahk": "autohotkey",

2) "code-runner.executorMap" settings: this is for language id of the language extension, not script extension.

So in my case, I need:

 "code-runner.executorMap": {
            "ah2": "\"J:\\StandaloneApps\\AutoHotkeyV2\\AutoHotkeyU64.exe\" /r /errorStdOut"
        }

Now will work with extensions associated with dudelmoser language extension: .ahk, .ah2, .ahk2

Thanks again for your kind help - it would have taken me longer without your help.

zero-plusplus commented 4 years ago

I'm glad I could solve it.

By the way, please close it when the problem is resolved. It's hard to see which one is currently unsolved. I can't close it, I suspect it's intentionally open because something hasn't been resolved yet.

SAbboushi commented 4 years ago

Look up formulahendry.code-runner and you might be happy.

VERY happy: nice to be able to run selected lines of code without having to create a test script, save it and then delete it after I'm done! Thank you!

SAbboushi commented 4 years ago

Do you see my comment when I close? I will "Close and comment" on this post - please confirm that you see it somehow (maybe email notification?)

zero-plusplus commented 4 years ago

It seems that Close and comment just closes after commenting as its name suggests.

It seems that they are executed as separate commands, and email notifications have come separately.

zero-plusplus commented 4 years ago

I noticed the [Run -> Run Without Debugging] in the vscode menu.

I thought it should be implemented in an extension that supports the AutoHotkey language, but this feels like a feature on the debugger side.

I need to investigate how it works in another debugger.

zero-plusplus commented 4 years ago

I decided to implement this feature. However, the script will terminate when you exit vscode due to the specification.

There are workarounds for this, but it's not a common behavior, so I'm not going to do it.

A complete solution to this problem will be provided in another extension under development.


Specifically, I will be implementing a feature similar to the Scite4AutoHotkey scriptlet.

scriptlet is a feature that allows you to run user-created utilities written in AutoHotkey. It would allow them to continue running scripts even if vscode exits.

However, development has been stopped due to busy maintenance. Progress is probably about 15% of the total.

Another reason for the delay is that the syntax highlighting configuration file is ten times larger the existing one. The quality is better for it.

Please be patient for a while longer as I will make sure it is completed.

SAbboushi commented 4 years ago

Another reason for the delay is that the syntax highlighting configuration file is ten times larger the existing one. The quality is better for it.

Looking forward to the syntax highlighting