View Full Version : OS_ShellExecute "document.chm" - how to close it?
ReneMiner
08-10-2015, 10:38
It seems impossible to shell a help-file-document using OS_Shell.
If it were possible to shell in ASync-mode then i would have some process-ID.
Just there is no way to check if the process with the given ID is still running since OS_ProcessIsRunning() awaits a process-name.
It works to use this for example:
Uses "OS"
' thinBasic-InstallPath has to be "C:\thinBasic\" for this
OS_ShellExecute("open", "thinBasic.chm", "", "C:\thinBasic\Help", %SW_SHOWNORMAL )
but this does not return any process-ID
How can i determine now if this help-file is already|still open (so not to open another one) ?
And how can i close it again when my script ends?
ReneMiner
29-11-2015, 12:35
Help!
How can i shell *.chm-help-files - and close them again when my script ends?
ErosOlmi
29-11-2015, 12:59
Do not shell, use native Windows API
The following is an abstract on ho I open help when you press F1 over a token.
Identify the token then pass it to a function similar to the following example.
The following example is a working thinBasic script using thinBasic.chm file as help and searching for "Dim" keyword.
You help file must be created with correct topics/keywords in order to search.
Ciao
Eros
Declare Function HtmlHelp Lib "hhctrl.ocx" Alias "HtmlHelpA" (
ByVal hwndCaller As DWord,
pszFile As Asciiz,
ByVal uCommand As DWord,
ByVal dwData As DWord) As DWord
Type HH_AKLINK
cbStruct As Long ' sizeof this structure
fReserved As Long ' must be FALSE (really!)
pszKeywords As Asciiz Ptr ' semi-colon separated keywords
pszUrl As Asciiz Ptr ' URL to jump to if no keywords found (may be NULL)
pszMsgText As Asciiz Ptr ' Message text to display in MessageBox if pszUrl is NULL and no keyword match
pszMsgTitle As Asciiz Ptr ' Message text to display in MessageBox if pszUrl is NULL and no keyword match
pszWindow As Asciiz Ptr ' Window to display URL in
fIndexOnFail As Long ' Displays index if keyword lookup fails.
End Type
%HH_KEYWORD_LOOKUP = &H000D
'------------------------------------------------------------------------------
' Open content sensitive help
'------------------------------------------------------------------------------
Function thinBasic_Help(ByVal hParent As Long, ByVal HelpKeyword As String) As Long
Local link As HH_AKLINK
Local sWord As String
Local hHlpWnd As DWord
Local lCounter As Long
sWord = Ucase$(Trim$(HelpKeyword)) + ";" + _
LCase$(Trim$(HelpKeyword)) + ";" + _
MCase$(Trim$(HelpKeyword))
link.cbStruct = SizeOf(HH_AKLINK)
link.fReserved = %FALSE
link.pszKeywords = StrPtr(sWord)
link.fIndexOnFail = %FALSE '---We will automatically do this
'---thinBasic help file
hHlpWnd = HtmlHelp(hParent, "c:\thinBasic\Help\thinBasic.chm" + $NUL, %HH_KEYWORD_LOOKUP, VarPtr(link))
If hHlpWnd <> 0 Then
'MsgBox 0, "Help found"
End If
End Function
thinBasic_Help(0, "Dim")
ReneMiner
29-11-2015, 13:10
yeah- that's one step beyond already... this would be the function for [F1]-key. :)
And can i just shell the file too - without to pass any keyword?-
Edit, nevermid. fIndexOnFail = True does it
ErosOlmi
29-11-2015, 18:38
Yes exactly.
I do not go into the index because on fail I need to loop though all user helps installed in thinBasic.
Researched keyword maybe is a keyword of other help files.
And only if I end without any keyword found ... I switch into thinBasic index.
%HH_KEYWORD_LOOKUP command info can be found in Microsoft documentation here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms670091(v=vs.85).aspx
with all other possible commands regarding help.