UPDATE: Solved. Thanks for the suggestions.
The registry entry at
HKEY_CLASSES_ROOT\.ahk seems to control the default action for .ahk files. i.e. runs them. Changing its value from ahk_auto_file to AutoHotkeyScript caused my .ahk files to open in Notepad2 instead of running when I double-clicked them.
Code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.ahk]
@="ahk_auto_file"
The
HKEY_CLASSES_ROOT\AutoHotkeyScript probably fixed or added the "Edit" option into the Explorer's right-click context menu for .ahk files, but not for "Edit This Script" in the in system tray menu.
The trick was to add the
Shell\Edit\Command @="C:\Program Files\Notepad2.exe %1" into
HKEY_CLASSES_ROOT\ahk_auto_file. Previously it only had an "Open" entry pointing to AutoHotkey.exe, but no "Edit" entry. Here's the .reg file for it:
Code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ahk_auto_file]
@=""
[HKEY_CLASSES_ROOT\ahk_auto_file\shell]
[HKEY_CLASSES_ROOT\ahk_auto_file\shell\Edit]
[HKEY_CLASSES_ROOT\ahk_auto_file\shell\Edit\Command]
@="\"C:\\Program Files\\Notepad2.exe\" \"%1\""
[HKEY_CLASSES_ROOT\ahk_auto_file\shell\open]
[HKEY_CLASSES_ROOT\ahk_auto_file\shell\open\command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"%1\""
I also kept the AutoHotkeyScript additions (shown below), but I'm not sure if it's doing anything since the .ahk key doesn't reference it.
Code:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AutoHotkeyScript]
[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell]
[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit]
[HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command]
@="\"C:\\Program Files\\Notepad2.exe\" \"%1\""