I've included this routine in my default hotkey script, at the request of my better half! I added a menu option to the tray menu and made it the default, so that double clicking the tray icon pops up the list of hotkeys. Not every hotkey is displayed, only those where a comment is delineated by a double semicolon ( ;; ). You can also add blank spacer lines with ;; on a line by itself. I have not bothered with sorting, they are just displayed as coded (good idea to have them sorted logically in the script anyway).
;*******************************************************************************
; Extract a list of hotkeys and their descriptions from this script
;*******************************************************************************
KeyList:
SetBatchLines,-1
AutoTrim,off
Loop,Read,%A_ScriptName%
{
Line=%A_LoopReadLine%
IfNotInString,Line,`;`;,Continue
Key=
IfInString,Line,`:`:
{
StringSplit,Key,Line,`:
StringReplace,Key,Key1,#,Win-
StringReplace,Key,Key,!,Alt-
StringReplace,Key,Key,^,Ctrl-
StringReplace,Key,Key,+,Shift-
StringReplace,Key,Key,`;,
Key=%key% !
}
StringLeft,key,key,15
StringSplit,Comment,Line,`;
StringTrimLeft,Comment,Comment%Comment0%,0
KeyList=%KeyList%%Key%`t%Comment%`n
}
MsgBox,0,Hotkeys list,%KeyList%
KeyList=
Return
The bit that does the tray menu...
Menu,Tray,Add,Hot&keys list,KeyList
Menu,Tray,Default,Hot&keys list
[/code]
And a couple of hotkey definitions, note the ;; comment
#A::run c:\windows\dosprmpt.pif ;;DOS prompt
#B::run C:\Program Files\SecCopy\SecCopy.exe ;;Backup (Second Copy)
#C::run control.exe ;;Control Panel
The result is a message box that contains...
Win-A DOS Prompt
Win-B Backup
Win-C Control panel
I've used tabs to try to keep the columns aligned, although it may not *always* work :-)