
How to "Edit this Script" in any editor other than
How do I change these default settings to open the script in Textpad ??

1. Open the registry editor: Click on run in your start menu and enter regedit and press enter
2. Scroll to the folder HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command
3. Double click on (Default) in the right pane
4. Change c:\windows\system32\notepad.exe to your preferred editor. I'm using PsPad: "c:\Program Files\PSPad editor\PSPad.exe" "%1" (All quotes included). The "%1%" is important, because windows replaced it by the file name you want to edit.

You can change this in your registry.
1. Open the registry editor: Click on run in your start menu and enter regedit and press enter
2. Scroll to the folder HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command
3. Double click on (Default) in the right pane
4. Change c:\windows\system32\notepad.exe to your preferred editor. I'm using PsPad: "c:\Program Files\PSPad editor\PSPad.exe" "%1" (All quotes included). The "%1%" is important, because windows replaced it by the file name you want to edit.
Thanks a Lot !

I like notepad++ as the best ahk editor since it understands its language (plugin)
REGEDIT4 [HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command] @="C:\\Program Files\\Notepad++\\notepad++.exe %1"

Is there a version of this tweak for Notepad2?
I have it located at C:\Program Files\Notepad2.exe, so I changed Lompsy's file to:
REGEDIT4 [HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command] @="C:\\Program Files\\Notepad2.exe %1"(I had no previous default value)
it didn't work, not even after a reboot. I then added the extra quotes per bits suggestion to make the registry value "C:\Program Files\Notepad2.exe" "%1", but again no luck... though I haven't rebooted yet in case that's required.
[Edit2]

Hardware: fast laptop with SSD
Software: Win 7 Home Premium 64-bit, android for phone and tablet
I've found Types to be handy, especially in Windows Vista and 7, which don't allow that level of control through the standard UI.
Source: Types
“Types” is a free and lightweight configuration utility for Windows that allows you to edit program associations, icons, context menus and other properties of various file types displayed in the Explorer.

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.
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:
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.
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\""

Hardware: fast laptop with SSD
Software: Win 7 Home Premium 64-bit, android for phone and tablet
Here's my Regedit files:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file] @="" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file\shell] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file\shell\Edit] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file\shell\Edit\Command] @="\"C:\\Program Files (x86)\\PSPad editor\\PSPad.exe\" \"%1\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file\shell\open] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ahk_auto_file\shell\open\command] @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"%1\""
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript] @="AutoHotkey Script" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\DefaultIcon] @="C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe,1" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell] @="Open" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Compile] @="Compile Script" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Compile\Command] @="\"C:\\Program Files (x86)\\AutoHotkey\\Compiler\\Ahk2Exe.exe\" /in \"%l\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit] @="Edit Script" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit\Command] @="\"C:\\Program Files (x86)\\PSPad editor\\PSPad.exe\" \"%1\"" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Open] @="Run Script" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Open\Command] @="\"C:\\Program Files (x86)\\AutoHotkey\\AutoHotkey.exe\" \"%1\" %*"
Any clue what's wrong?

The registriy enties do not have any effect on "Edit this script" - it always opens NotePad with the script.
BTW HKEY_CLASSES_ROOT\.ahk points to AutoHotkeyScript (not to ahk_auto_file).
How to fix this?

EDIT: Actually, now that I think about it, it likely doesn't matter how AHK is launching the editor, even if it's through ShellExecute, since it will be the 32-Bit version of Shell32.dll anyway.

I have not found the branch HKEY_CLASSES_ROOT\Software\Wow6432Node\Classes (as You suggest to put copies in).
There is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\ahkfile\shell\Edit\Command which may just be a copy of the HKCLR branch.
Still confused, but on a higher level
Klaus

Also the second path you provided is just fine, so you can update the data there. It's actually the same location, it just gets merged with other keys and virtualized as HKCR. However, it is still the ultimate place where 32-Bit apps will get their data (read: have to go) to look up file association information, including the 32-Bit version of Shell32.
As far as 64-Bit versions of AHK go, only AHK_L provides 64-Bit versions (as well as Unicode versions). AHK basic only provides a 32-Bit version in ANSI. If your AutoHotkey.exe file version number is 1.0.48.05, then chances are it's the basic version.

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit\Command
Value = pspad.exe %1
