HTML Help alternative via Internet Explorer
Posted: 29 Dec 2017, 22:49
- Here is a prototype, 2 windows: a treeview and Internet Explorer, as an alternative to HTML Help.
- At the moment it displays the Contents, I might try and add in support for the Index, Search (a superior search, equivalent to FileRead and InStr) and Favorites.
- I'm also going to incorporate support for switching between the AHK v1/v2 help pages.
- To view the contents of a chm file, you can decompile it using HTML Help or 7-Zip. The older version of the AutoHotkey.chm file has 'Table of Contents.hhc' (the basis of the Contents list). Both the new and old versions have 'Index.hhk' (the basis of the Index list). The Favorites are stored in %AppData%\Microsoft\HTML Help\hh.dat, which contains information for all of the chm files that have ever been run, back it up if you intend to edit it. (It's a binary file so you can't edit it in Notepad, use HxD or some other program.)
- The best current workaround is to use an old version of the contents list, and the new version of the index list. The Search would search for text within any pages listed in either the old contents list or the new index list. The Favorites would be based on an ini file, and/or a hardcoded template in the script.
- Btw a new version of 'Table of Contents.hhc' is ideally needed, otherwise the Contents would be missing a few pages. Newer pages would still be accessible by clicking hyperlinks.
[EDIT:] It appears that the data is stored here in the new version:
docs\static\source\data_index.js and docs\static\source\data_toc.js
- I first worked on this at the beginning of the year, in January. I wanted to retrieve the contents of the Contents table directly from the .hhc file (retrieved by decompiling the chm), rather than by getting text via a treeview control.
- At the time, I wanted to combine the benefits of Internet Explorer with the benefits of the HTML Help treeview control.
- What's changed now is that I've figured out a way to get the contents of the .hhc/.hhk files, direct from the chm file, without decompiling it, but to do this you must already know the relative paths of those 2 files. (I found that out by decompiling.)
- At the moment it displays the Contents, I might try and add in support for the Index, Search (a superior search, equivalent to FileRead and InStr) and Favorites.
- I'm also going to incorporate support for switching between the AHK v1/v2 help pages.
- To view the contents of a chm file, you can decompile it using HTML Help or 7-Zip. The older version of the AutoHotkey.chm file has 'Table of Contents.hhc' (the basis of the Contents list). Both the new and old versions have 'Index.hhk' (the basis of the Index list). The Favorites are stored in %AppData%\Microsoft\HTML Help\hh.dat, which contains information for all of the chm files that have ever been run, back it up if you intend to edit it. (It's a binary file so you can't edit it in Notepad, use HxD or some other program.)
- The best current workaround is to use an old version of the contents list, and the new version of the index list. The Search would search for text within any pages listed in either the old contents list or the new index list. The Favorites would be based on an ini file, and/or a hardcoded template in the script.
- Btw a new version of 'Table of Contents.hhc' is ideally needed, otherwise the Contents would be missing a few pages. Newer pages would still be accessible by clicking hyperlinks.
[EDIT:] It appears that the data is stored here in the new version:
docs\static\source\data_index.js and docs\static\source\data_toc.js
- I first worked on this at the beginning of the year, in January. I wanted to retrieve the contents of the Contents table directly from the .hhc file (retrieved by decompiling the chm), rather than by getting text via a treeview control.
- At the time, I wanted to combine the benefits of Internet Explorer with the benefits of the HTML Help treeview control.
- What's changed now is that I've figured out a way to get the contents of the .hhc/.hhk files, direct from the chm file, without decompiling it, but to do this you must already know the relative paths of those 2 files. (I found that out by decompiling.)
Code: Select all
;HTML Help alternative via Internet Explorer by jeeswg
;settings
vFontSize := 20
vFontName := "Verdana"
;older chm containing contents information:
vPath1Old := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
;up-to-date chm:
vPath1 := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
;vPath1 := "https://autohotkey.com"
;==================================================
OnExit("ExitFunc")
;e.g. https://autohotkey.com/docs/commands/SubStr.htm
;e.g. mk:@MSITStore:C:\Program%20Files\AutoHotkey\AutoHotkey.chm::/docs/commands/SubStr.htm
;e.g. its:C:\Program%20Files\AutoHotkey\AutoHotkey.chm::/docs/commands/SubStr.htm
;e.g. https://autohotkey.com/Table of Contents.hhc
;e.g. mk:@MSITStore:C:\Program%20Files\AutoHotkey\AutoHotkey.chm::Table of Contents.hhc
;e.g. its:C:\Program%20Files\AutoHotkey\AutoHotkey.chm::Table of Contents.hhc
if (SubStr(vPath1, 1, 4) = "http")
vPath1X := vPath1 "/"
else
vPath1X := "its:" vPath1 "::/"
oWB := ComObjCreate("InternetExplorer.Application")
;oWB.Navigate("its:" vPath1Old "::Index.hhk")
oWB.Navigate("its:" vPath1Old "::Table of Contents.hhc")
;oWB.Visible := True
vHtml := oWB.document.documentElement.innerText
;MsgBox, % vHtml
oWB.Quit()
oWB := ""
oHTML := ComObjCreate("HTMLFile")
oHTML.write(vHtml)
vOutput := ""
VarSetCapacity(vOutput, 1000000*2)
Loop, % oHTML.getElementsByTagName("object").length
{
oElt := oHTML.getElementsByTagName("object")[A_Index-1]
if (oElt.type = "text/site properties")
continue
vTitle := vUrl := ""
if (oElt.childNodes.length > 0)
vTitle := oElt.childNodes[0].getAttribute("value")
if (oElt.childNodes.length > 1)
vUrl := oElt.childNodes[1].getAttribute("value")
vIndent := ""
Loop
{
oElt := oElt.parentNode.parentNode.parentNode.childNodes[0]
vTitle2 := oElt.childNodes[0].getAttribute("value")
if !(vTitle2 = "") && !(oElt.type = "text/site properties")
vIndent .= "`t"
else
break
}
vOutput .= vIndent vTitle "`t" vUrl "`r`n"
}
;trim trailing tabs
vOutput := RegExReplace(vOutput, "m)`t+$")
;MsgBox, % "done"
;return
Clipboard := vOutput
;==================================================
vText := vOutput
oWB := ComObjCreate("InternetExplorer.Application")
oWB.Navigate(vPath1X "docs/AutoHotkey.htm")
oWB.Visible := True
DetectHiddenWindows, On
vCtlW := 280
vCtlW := 480
;vCtlW := 680
Gui, +HwndhGui
Gui, Font, % "s" vFontSize, % vFontName
Gui, +Resize
Gui, Add, TreeView, % "vMyTreeView x0 y0 w" vCtlW " gMyTreeView ImageList" ImageListID " AltSubmit +HwndhLV"
Gui, Add, Button, Hidden Default, OK
ImageListID := IL_Create(5)
Loop, 5
IL_Add(ImageListID, "shell32.dll", A_Index)
vParentItemID1 := 0
Loop, Parse, vText, `n, `r
{
vTemp := A_LoopField
if (vTemp = "")
continue
vGen := 1
Loop, Parse, vTemp
{
if (A_LoopField = "`t")
vGen++
else
break
}
vTempX := SubStr(vTemp, vGen)
vGen2 := vGen+1
oTemp := StrSplit(vTempX, "`t")
vParentItemID := vParentItemID%vGen%
vItemID := TV_Add(oTemp.1, vParentItemID, "Icon4")
vText%vItemID% := oTemp.2
vParentItemID%vGen2% := vItemID
}
;WinGetPos,,,, vCtlH, % "ahk_id " hLV
WinGetPos,,,, vTaskbarH, ahk_class Shell_TrayWnd
vCtlH := (A_ScreenHeight-vTaskbarH)
Gui, Show, % "x0 y0 w" vCtlW " h" vCtlH, AutoHotkey Help
WinGetPos,,, vWinW,, % "ahk_id " hGui
vWin2W := (A_ScreenWidth-vWinW)
WinMove, % "ahk_id " oWB.HWND,, % vWinW, 0, % vWin2W, % vCtlH
return
;==================================================
MyTreeView:
if (A_GuiEvent = "DoubleClick")
|| (A_GuiEvent = "Normal")
{
vItemID := A_EventInfo
vText := vText%vItemID%
;if !(vText = "")
; ToolTip, % vText
;else
; ToolTip
if !(vText = "")
oWB.Navigate(vPath1X vText, hWnd)
;return
}
;if A_GuiEvent in DoubleClick,Normal
; ToolTip, % A_GuiEvent " " A_MSec
return
;==================================================
GuiSize:
if (A_EventInfo = 1)
return
GuiControl, Move, MyTreeView, % "H" (A_GuiHeight - 30) ; -30 for status bar and margins
return
;==================================================
GuiClose:
ExitApp
;==================================================
ButtonOK:
GuiControlGet, vCtlName, FocusV
if !(vCtlName = "MyTreeView")
return
vItemID := TV_GetSelection()
vText := vText%vItemID%
if !(vText = "")
oWB.Navigate(vPath1X vText, hWnd)
vState := TV_Get(vItemID, "Expand")
if TV_GetChild(vItemID)
if (vState := TV_Get(vItemID, "Expand"))
TV_Modify(vItemID, "-Expand")
else
TV_Modify(vItemID, "Expand")
return
;==================================================
ExitFunc()
{
global oWB
oWB.Quit()
oWB := ""
}
;==================================================
;q::
Gui, Show
return
;==================================================