mark-wiemer-org / ahkpp

AHK++ provides AutoHotkey v1 and v2 support for VS Code, Theia IDE, and more
https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus
Other
178 stars 10 forks source link

Run script as ahk v1 #391

Closed Sperhak323 closed 1 year ago

Sperhak323 commented 1 year ago

How to run script as ahk v1? I cannot find any button or something. When i try run script with ctrl+F9 I get error from ahk because run it in v2 and i have script in v1 Thanks for reply.

mark-wiemer commented 1 year ago

Hi @Sperhak323, please check out these settings:

  1. The language mode is set to AHK v1 (you can use F1 to bring up the command palette, then search "Change Language Mode")
  2. The path to the v1 interpreter in the settings is correct

If you're still struggling, please paste a small script you're trying to run and some screenshots of your settings so I can assist further.

Sperhak323 commented 1 year ago

Thanks, first step works.

fade2gray commented 1 year ago

@mark-wiemer

The language mode is set to AHK v1...

I've noticed, if you create a new empty text file in explorer with an ahk extension and use the context menu to open it with VSCode, the file will be opened by default in v2 mode.

mark-wiemer commented 1 year ago

Yep @fade2gray, somehow it's defaulting to AHK v2 even though I don't want it to :/ I'm at work rn, feel free to open a bug for that but you should be able to change the default language association for .ahk files to AHK v1 :)

helperman commented 1 year ago

@fade2gray By the way, do you know any way to automatically convert ahk-script from v1 to v2? It's qute tedious to do it manually.

fade2gray commented 1 year ago

That's why I posted my comment - I noticed that you posted a similar comment but deleted it.

https://github.com/mmikeww/AHK-v2-script-converter is a help, but it won't do it all for you.

helperman commented 1 year ago

@fade2gray how good it is when there are people like you in the world who will help when it's needed. I've just found the solution that's why I deleted my comment.

hubisan commented 1 year ago

It is possible to set the default language for a file extension^1.

Add this to your settings file to associate .ahk with ahk v1:

  "files.associations": {
      "*.ahk": "ahk"
  }

Use "ahk2" for ahk v2.

You can also associate specific folders to a certain language^2:

"files.associations": {
    "**/somefolder/*.*": "ahk",
    "**/otherfolder/*.*": "ahk2"
}

A glob pattern^3 is used for file matching.

fade2gray commented 1 year ago

I find that using .ah1 and .ah2 extensions just work out-of-the-box - no need for #Requires blah.