Pressing F1 on a keyword in
Notepad2, will open the relevant keyword's page in the AHK help file.
Origianally created for use with Notepad2 and AHK help file, but can be configured to work with any text editor and any file extension.
All that is needed is a help file for that extension (i.e. a help file for PHP, or CSS or whatever) that has a page for each function, like the AHK help file has.
Also, Notepad2 users - make sure that the window title shows full path (Settings -> Window Title Display)
Code:
;-------------------------------------------------------------------------------
;
; CHM Notepad Assist
; Context sensitive function reference help from any text editor
;
; To add languages:
; • Open your reference CHM in one of the command references pages
; • Right click on the page -> properties and copy the URL
; • Create additional two variables in the configuration area for your
; • extension
;
; To change text editor:
; • Edit the #IfWinActive line to match the title of your text editor
; • Edit the RegExMatch in the CopyAndShow label
;
; To use:
; • Open a supported file in the configured text editor
; • Put the caret somewhere in the middle of a function or select it
; • Press F1
;
;-------------------------------------------------------------------------------
VersionString := "0.10"
NameString := "CHM Notepad Assist"
#SingleInstance Force
SetTitleMatchMode RegEx
; CONFIGURE
;_______________________________________________________________________________
FilePath_PHP := "D:\Books\PHP\php_manual_en.chm"
BaseURL_PHP := "mk:@MSITStore:%FilePath_PHP%::/en/function.%function%.html"
FilePath_AHK := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
BaseURL_AHK := "mk:@MSITStore:%FilePath_AHK%::/docs/commands/%function%.htm"
;_______________________________________________________________________________
Return
ShowFunction( function, lang="ahk" ) {
Local ThisUrl
If( lang="php" )
StringReplace function, function, _, -, All ; For the PHP help
Else
function := RegexReplace( function, "\W", "_" ) ; For other helps
Transform ThisUrl, DeRef, % BaseURL_%lang%
Run hh.exe %ThisUrl%
}
CopyAndShow:
; Extract extension from the window title
WinGetTitle WinTitle, A
RegExMatch( WinTitle, ".*\.(\w+) - Notepad2", RX_Token )
Lang := RX_Token1
; First, assume we have a text already selected and try to copy it
Clipboard =
SendInput ^c
ClipWait 0.5
; If we got nothing, attempt to make a selection where the cursor is
If( Clipboard = "" ) {
SendInput ^{Left}^+{Right}^c
ClipWait 1
}
If( Clipboard = "" )
Return
; Trim spaces and launch the CHM
Function = %Clipboard%
ShowFunction( Function, Lang )
Return
#IfWinActive .*\.(\w+) - Notepad2
F1::Gosub CopyandShow
_________________
Sector-Seven - Freeware tools built with AutoHotkey