S4AHK takes over .ahk file association

The popular SciTE-based AutoHotkey Script Editor
lexikos
Posts: 9494
Joined: 30 Sep 2013, 04:07
Contact:

S4AHK takes over .ahk file association

Post by lexikos » 22 Sep 2022, 20:13

Using "Open with" to open a file in SciTE4AutoHotkey 3.1.0 may cause it to "take over" the .ahk file type association.

I believe this is a Windows bug, triggered by use of the OpenWithProgID method of registering for "Open with". Using "Open with" to change the default program back to AutoHotkey is probably the easiest solution.

A workaround has been applied by commit 49c3fe5 but this has not yet been included in a SciTE4AutoHotkey update.

The following is from a discussion between fincs and myself about this issue.
lexikos wrote:
16 May 2022, 04:50
I am aware that changing the default program via any official GUI within the OS - such as open-with, a file's properties window or the Settings app - creates an additional association via the UserChoice subkey under FileExts that overrides the default value of HKCR\.ahk created by setup. I generally choose to delete any such key to let the default value take effect, rather than overriding it with a redundant value.

When I select SciTE from the open-with menu, .ahk files become associated with SciTE, but the icon doesn't change unless I call SHChangeNotify or restart Explorer. (Actually, the icon in the Windows 11 context menu does update immediately.) I checked the usual places and trawled the registry, and could not find anything associating .ahk files with SciTE. Normally if the user actually chooses to change the default program, Windows creates a key ...\FileExts\.ahk\UserChoice. This still doesn't exist. I guessed it was in memory somehow, but it stays associated with SciTE after restarting Explorer, and I have no idea how.

Normalcy returns if I do any of these things:
  • Open-with Ahk2Exe GUI. There is no connection between the Ahk2Exe registration or the program itself and the AutoHotkeyScript ProgID. The difference between Ahk2Exe and SciTE is that I registered Ahk2Exe under OpenWithList while experimenting.
  • Open-with Notepad by selecting "choose another app" and browsing to it.
  • Open-with Notepad from the menu, now that it appears there.
  • Open-with AutoHotkey, of course.
  • Activate any context menu item that comes from a verb defined under HKCR\SystemFileAssociations\.ahk, even if the command is literally just notepad.
    [...]
That is, .ahk files once again become associated with AutoHotkey and all of the normal context menu options return. Note that I am not choosing to set the default program for .ahk files, just performing a one-time open-with, so the problem returns if I open-with SciTE again.

I tried changing SciTE's "open" verb to "edit", but this only had the effect of changing the icon (after it refreshes) from the SciTE application icon to a blank page containing a smaller SciTE icon.
lexikos wrote: I did some testing with a dummy file extension to isolate the problem. The problem occurred with SciTE and Notepad++, but not Notepad. By comparing the three, I found that registering under HKCR\Applications\SciTE.exe and setting a NoOpenWith (blank) value there prevents the problem from occurring.

I'm pretty sure the weird behaviour is a Windows bug. It doesn't appear to affect Windows 7.

Return to “SciTE4AutoHotkey”