AutoHotkey Community

It is currently May 26th, 2012, 5:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: April 15th, 2009, 8:49 am 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 17th, 2009, 6:35 pm 
Offline

Joined: January 7th, 2009, 7:03 pm
Posts: 43
Awesome stuff dude, keeps me from having to type it in =D

Here is PSPad version with AHK only

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_AHK := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
BaseURL_AHK  := "mk:@MSITStore:%FilePath_AHK%::/docs/commands/%function%.htm"
;_______________________________________________________________________________

Return

ShowFunction( function, lang="ahk" ) {
  Local ThisUrl
    function := RegexReplace( function, "\W", "_" ) ; For other helps
  Transform ThisUrl, DeRef, % BaseURL_%lang%
  Run hh.exe %ThisUrl%
}

CopyAndShow:
  Lang := "ahk"
 
  ; 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 PSPad
F1::Gosub CopyandShow


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group