DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

19 Feb 2018, 12:54

Hello,
I found out how to start a window help file (chm) file on a specific position:

Code: Select all

HelpFilePath = c:\Program Files\AutoHotkey\AutoHotkey.chm
HTML = /docs/commands/Random.htm
run, C:\Windows\hh.exe %HelpFilePath%::%HTML%  
But I am searching now for hours how to jump to a specific topic on an existing window.
Here is the best code I could find so far.
https://autohotkey.com/board/topic/1298 ... ific-page/
(see post of PhiLho)

But I can not bring it to work. Well its 13 years ago..
Even the simple start of an chm file does not work.

Code: Select all

hh_Function = HHCtrl.ocx\HtmlHelpA
_helpFile = c:\Program Files\AutoHotkey\AutoHotkey.chm
HH_DISPLAY_TOPIC = 0x00

DllCall(hh_Function
, "UInt", 0	; hwndCaller
, "Str", _helpFile
, "UInt", HH_DISPLAY_TOPIC
, "UInt", 0)
The jump to specific page on an existing window must be something like

Code: Select all

hh_Function = HHCtrl.ocx\HtmlHelpA
_helpFile = c:\Program Files\AutoHotkey\AutoHotkey.chm
HH_DISPLAY_TOPIC = 0x00
HTML = /docs/commands/Random.htm

DllCall(hh_Function
, "UInt", 0	; hwndCaller
, "Str", _helpFile "::" HTML
, "UInt", HH_DISPLAY_TOPIC
, "UInt", 0)
Can anyone help please?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

19 Feb 2018, 16:38

- Try this.

Code: Select all

q:: ;AutoHotkey Help (HTML Help) - navigate to page
vPathChm := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
vPath := vPathChm "::/docs/commands/Random.htm"

if !hModuleHH
	hModuleHH := DllCall("kernel32\LoadLibrary", Str,"hhctrl.ocx", Ptr)

;HtmlHelp function (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms670172(v=vs.85).aspx

;from HtmlHelp.h:
;HH_DISPLAY_TOPIC := 0x0

DllCall("hhctrl.ocx\HtmlHelp" (A_IsUnicode?"W":"A"), Ptr,0, Str,vPath, UInt,0, UInt,0)
return
- Btw great PhiLho link, thanks for sharing.
- Another useful link, to code by teadrinker:
F1 help not jumping to particular URL with v1.1.27.00 help file - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 55#p191155

- Here's an alternative using the WBGet function, to operate on the Internet Explorer_Server control:

Code: Select all

;WBGet function - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=39869

q:: ;AutoHotkey Help (HTML Help) - navigate to page
vPathChm := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
vPath := vPathChm "::/docs/commands/Random.htm"
WinGet, hWnd, ID, AutoHotkey Help ahk_class HH Parent
if hWnd
{
	oWB := WBGet("ahk_id " hWnd)
	oWB.Navigate("its::" vPath)
	oWB := ""
}
else
	Run, hh.exe "%vPath%"
return
- I've added some of these links here:
jeeswg's Internet Explorer and HTML tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 64#p148164
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

20 Feb 2018, 02:45

Thank you jeeswg. Phantastic. The first one works perfect.

It seams that on the PhiLho page only the LoadLibrary is missing.

Maybe that example could be implemented into the autohotkey help. Do you know how to contact them?

On your second solution I get the Error "Call to nonexistend function" in the row oWB := WBGet("ahk_id " hWnd)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

20 Feb 2018, 12:22

- Yes, without the LoadLibrary line, it appears to crash AutoHotkey.
- There's all sorts of good code, that shouldn't appear in the help. When I complete my beginner tutorial, I might put some links there, to make certain things easier to find. I might put a link here also:
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596
- The WBGet function is a custom function, you need to copy and paste it into your script, I provided a link above.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 03:08

Hello again,
I have now tested you first code and after some calls the called chm window freezes and the used RAM is going up. On a 4GB System (Win 7) after about 30 seconds the message "too less RAM" appears and the application is crashing.
If you use the code below you will see, that on every call the RAM is increasing. Is it necessary to unload the Library?
The chm files I use are 6 to 8 time the size as AutoHotkey.chm is. It seams the RAM increases every time by the size of the chm file.

The code I use is:

Code: Select all

#Persistent
#SingleInstance force
Hotkey, F1, F1Hotkey ;have to switch it on and off
hModuleHH =
return


F1Hotkey:
vPathChm := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
vPath := vPathChm "::/docs/commands/Random.htm"

if !hModuleHH
	hModuleHH := DllCall("kernel32\LoadLibrary", Str,"hhctrl.ocx", Ptr)

;HtmlHelp function (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms670172(v=vs.85).aspx

;from HtmlHelp.h:
;HH_DISPLAY_TOPIC := 0x0

DllCall("hhctrl.ocx\HtmlHelp" (A_IsUnicode?"W":"A"), Ptr,0, Str,vPath, UInt,0, UInt,0)
return
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 03:17

You could try adding this line:

Code: Select all

DllCall("kernel32\FreeLibrary", Ptr,hModuleHH)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 06:06

Code: Select all

#Persistent
#SingleInstance force
Hotkey, F1, F1Hotkey ;have to switch it on and off
hModuleHH =
return


F1Hotkey:
vPathChm := "C:\Program Files\AutoHotkey\AutoHotkey.chm"
vPath := vPathChm "::/docs/commands/Random.htm"

if !hModuleHH
	hModuleHH := DllCall("kernel32\LoadLibrary", Str,"hhctrl.ocx", Ptr)

;HtmlHelp function (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/ms670172(v=vs.85).aspx

;from HtmlHelp.h:
;HH_DISPLAY_TOPIC := 0x0

DllCall("hhctrl.ocx\HtmlHelp" (A_IsUnicode?"W":"A"), Ptr,0, Str,vPath, UInt,0, UInt,0)
DllCall("kernel32\FreeLibrary", Ptr,hModuleHH)
return
crashes immediately
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 06:38

The second code from you with

Code: Select all

WBGet("ahk_id " hWnd)
does not increase the mount of RAM used. This seams to be the better solution.
Dolphin2000
Posts: 7
Joined: 19 Feb 2018, 12:26

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 09:10

Hello jeeswg,
I have written in AHK a complete software to show Microsoft Office 2013 VBA Offline Help for Office 2016 (which has no offline help) when ever F1 is pressed in an VBA Editor.
Works great.
I want to bring it out for free to the public, but I am not sure if I am allowed to provide a software with calls and display a windows help.
I also put the topics of the Microsoft help files in txt files for quicker search (made with Excel). Here I am also not sure if this is allowed. Maybe I have to produce the txt files by the software itself temporary.
Do you think I can post the complete code here in a forum? Will people how makes VBA programming in Microsoft Excel find it and compile it?
Do you think I shall ask Microsoft for permission?
Can you please give me an advice?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: DLLCall: Call a topic on existing help window (CHM) with hhctrl.ocx\HtmlHelpA

21 Feb 2018, 13:32

- It's good that Internet Explorer_Server method is working, but I will try to investigate the HTML Help API further, and would welcome anyone else to do the same.

- I remember some annoyance I had with Excel 2007, and so since then have kept some chm files from MS Office 2003, for general help and for macros. Out of interest, I could test any script you write on those files.
- I generally welcome the idea of being able to use offline help as a first resort, since it's faster, and the Internet connection might be down.

- I would share a script and say that that it works with the XXX.chm file(s) from version(s) XXX(-XXX) of MS Office.
- I wouldn't provide those XXX.chm files, but I would give advice to someone who owns MS Office regarding how to find those chm files.
- Ideally I would avoid sharing a hardcoded list of topics. To produce a list *temporarily* such as you described, the following link may be helpful:
HTML Help alternative via Internet Explorer - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=42129
- Essentially, you can use 7-Zip to decompile a chm, to get a feel for the internal file hierarchy, and then, in the script proper, read the html from specific pages, direct from the chm file. I will add more to that link in future.
- I don't have any specific knowledge that makes me well-placed to give such advice, so any advice here is only my best efforts.
- Further information, much of it relevant to HTML Help, is available here:
jeeswg's Internet Explorer and HTML tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31766
- Best of luck.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Xtra and 128 guests