If you don't mind using a different key than F1, you could use your own shortcut
(e.g. Alt-F1) with this little IDE Tool
(needs no arguments).
Code: Select all
EnableExplicit
If CreateMutex_(0, 1, "Win32.chm") = 0 Or GetLastError_() <> 0
PostMessage_(FindWindow_(0,"Win32 Programmer's Reference"), #WM_CLOSE, 0, 0)
EndIf
Prototype HtmlHelp(a, b.s, c, d)
#HH_DISPLAY_TOPIC = 0
#HH_DISPLAY_TOC = 1
#HH_KEYWORD_LOOKUP = $D
Structure tAKLIN
cbStruct.l
fReserved.l
pszKeywords.s
pszUrl.s
pszMsgText.s
pszMsgTitle.s
pszWindow.s
fIndexOnFail.l
EndStructure
Procedure HtmlHelp(HelpFile.s, Keyword.s) ;by ts-soft (https://www.purebasic.fr/english/viewtopic.php?p=355981#p355981)
Protected AKLIN.tAKLIN
Protected HtmlHelp_.HtmlHelp
Protected hWnd
Protected DLL = OpenLibrary(#PB_Any, "HHCtrl.ocx")
If DLL
CompilerIf #PB_Compiler_Unicode
HtmlHelp_ = GetFunction(DLL, "HtmlHelpW")
CompilerElse
HtmlHelp_ = GetFunction(DLL, "HtmlHelpA")
CompilerEndIf
With AKLIN
\cbStruct = SizeOf(tAKLIN)
\fReserved = 0
\pszKeywords = Keyword
\fIndexOnFail = #True
EndWith
hWnd = HtmlHelp_(0, HelpFile, #HH_KEYWORD_LOOKUP, AKLIN)
HtmlHelp_(0, HelpFile, #HH_DISPLAY_TOC, 0)
CloseLibrary(DLL)
ProcedureReturn hWnd
EndIf
EndProcedure
Define chm$ = "D:\Program Files\PureBasicTools\Win32.chm"
Define word$ = RTrim(GetEnvironmentVariable("PB_TOOL_Word"), "_")
Define hWnd_chm = HtmlHelp(chm$, word$)
If hWnd_chm
While IsWindow_(hWnd_chm)
Delay(1000)
Wend
EndIf
[/size]Edit: fixed mix-up with constants
(#HH_DISPLAY_TOPIC = 0, #HH_DISPLAY_TOC = 1), changed the order of execution
(#HH_KEYWORD_LOOKUP before #HH_DISPLAY_TOC) to provide a better experience
