Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AHK V1 files language mode is always set to AutoHotkeyV2 #396

Closed
GaryAtlan82 opened this issue Aug 14, 2023 · 11 comments · Fixed by #397
Closed

AHK V1 files language mode is always set to AutoHotkeyV2 #396

GaryAtlan82 opened this issue Aug 14, 2023 · 11 comments · Fixed by #397
Assignees
Labels
bug something isn't working language mode v1 scripts wrongly identified as v2 or vice versa

Comments

@GaryAtlan82
Copy link

Since update to the latest version V1 files, .ahk, are recognised as V2 files, by this I mean the current language mode is set to AutoHotkeyV2.
I have yet to start using V2, a few libraries that I count on have yet to ported over to V2, so I use V1 only for now.

Is there setting to prioritise V1, or to reserve .ahk extension for V1.

The following is typical of the first few lines of my .ahk files. Is this not enough to know this is for AHK V1 files?

#singleinstance, force
#Persistent
#NoEnv
#Warn, All, OutputDebug
#MaxHotkeysPerInterval 500
SetBatchLines, -1
DetectHiddenWindows, On
SetTitleMatchMode 2 
; SetTitleMatchMode, RegEx

#include <TapHoldManager>
#Include <FindText>
#include <UIA_Browser>
Latest AutHotkey V1
Latest AHK++ Extension Update
Code Version: 1.78.1 
Code Electron: 22.5.1
Code Chromium: 108.0.5359.215
Code Node.js: 16.17.1
Windows 11
@GaryAtlan82 GaryAtlan82 added the bug something isn't working label Aug 14, 2023
@mark-wiemer
Copy link
Member

mark-wiemer commented Aug 14, 2023

  1. Open a .ahk file
  2. F1 -> "Change language mode"
  3. Configure file association for .ahk
  4. AutoHotkey v1

Alternatively, you can rename your .ahk files to have .ah1 or .ahk1 extensions

Finally, you can add #Requires AutoHotkey v1 to each of your files--that's how the extension determines language mode for now, as it's the most definitive and simple way to do things :)

I've updated the v5 changelog with all of these notes as it wrongly claimed these files defaulted to AHK v1--thank you for reporting this.

@mark-wiemer mark-wiemer added the language mode v1 scripts wrongly identified as v2 or vice versa label Aug 14, 2023
@GaryAtlan82
Copy link
Author

GaryAtlan82 commented Aug 14, 2023

Hey thanks!

Alternatively, you can rename your .ahk files to have .ah1 or .ahk1 extensions

This would be the most sensible thing to do but I always end breaking something when I mass rename files. For example paths inside scripts ending with .ahk.

F1 -> "Change language mode"

I would like to avoid doing this, I understand in one of situations though.

Configure file association for .ahk

What do you mean by this? Are you reffering to the File Explorer "Open with..." feature? I was not aware you can fix this issue here, if so this would be an ideal fix for people who use V1/V2

@mark-wiemer
Copy link
Member

mark-wiemer commented Aug 14, 2023

When the "change language mode" picker appears, you have the option of changing it for just that one file or to "configure file association for .ahk", (i.e. all .ahk files). Your choice is saved in your settings and you should only have to do it once and it should apply to all your projects!

@GaryAtlan82
Copy link
Author

I was not aware of this at all. I will give this ago tomorrow. Thanks!

@GaryAtlan82
Copy link
Author

Hey, I was able to give your solution ago and sure enough you was right. It was a much better solution than the awfull one I had in mind. Thanks allot for that.

@fade2gray
Copy link

fade2gray commented Sep 8, 2023

@mark-wiemer May be best to create a separate pinned issue for this #396 (comment)? - I can see this being a frequent issue for those who have not updated yet.

@mark-wiemer
Copy link
Member

Good idea. I'm a bit busy rn but I will update the bug template shortly and pin an FAQ bug for easy access :)

@mark-wiemer mark-wiemer pinned this issue Sep 11, 2023
@wenfangdu
Copy link

Another way is to paste:

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

In to the vscode settings.json.

@mark-wiemer
Copy link
Member

To do a full uninstall and re-install of AHK++: There are some special locations where VS Code keeps a copy of all extensions, even after you uninstall them. I find those locations using the "Everything" search engine. Looks like it's under C:\Users\%user%\.vscode\extensions\mark-wiemer.vscode-autohotkey-plus-plus-5.0.3 by default, try removing that folder entirely and then uninstalling.

Note that your settings will be preserved as they're stored in C:\Users\%user%\AppData\Roaming\Code\User\settings.json :) (note this folder is hidden in File Explorer by default)

@mark-wiemer
Copy link
Member

Ref #445 for cleaner instructions :)

@doggy8088
Copy link

Another way is to paste:

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

In to the vscode settings.json.

I think this setting should be mentioned on extension page: https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working language mode v1 scripts wrongly identified as v2 or vice versa
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants