Hi
Done
Desktop handle was used instead of Sublime foreground window because of problems when WinHelp popup window is displayed.
This is only a draft whole functionality, however it is quite useful.
Example for Python help:
[code]# -- coding: utf-8 --
import ctypes
from ctypes.wintypes import BOOL
import os
import sublime, sublimeplugin
def _T(string):
if isinstance(string, str):
string = unicode(string, ‘utf-8’)
return string
HH_KEYWORD_LOOKUP = 0x000D
class c_tchar_p(ctypes._SimpleCData):
type = ‘Z’ # c_wchar_p
class HH_AKLINK(ctypes.Structure):
fields = (
(‘cbStruct’, ctypes.c_int), # sizeof this structure
(‘fReserved’, BOOL), # must be FALSE (really!)
(‘pszKeywords’, c_tchar_p), # semi-colon separated keywords
(‘pszUrl’, c_tchar_p), # URL to jump to if no keywords found (may be NULL)
(‘pszMsgText’, c_tchar_p), # Message text to display in MessageBox if pszUrl is NULL and no keyword match
(‘pszMsgTitle’, c_tchar_p), # Message text to display in MessageBox if pszUrl is NULL and no keyword match
(‘pszWindow’, c_tchar_p), # Window to display URL in
(‘fIndexOnFail’, BOOL) # Displays index if keyword lookup fails.
)
class CustomHelpCommand(sublimeplugin.TextCommand):
def run(self, view, args):
selected = ]
for region in view.sel():
selected.append(view.substr(view.word(region)) if region.empty() else view.substr(region))
selected = ‘;’.join(selected)
print ‘Displaying help topics for:’, selected
ak = HH_AKLINK(ctypes.sizeof(HH_AKLINK), False, _T(selected), None, None, None, None, True)
HtmlHelp = ctypes.windll.LoadLibrary('hhctrl.ocx').HtmlHelpW
HtmlHelp(ctypes.windll.user32.GetDesktopWindow(), _T('C:\\Python25\\Doc\\Python25.chm'), HH_KEYWORD_LOOKUP, ctypes.byref(ak))
def isEnabled(self, view, args):
return True[/code]
and binding key:
<bindings>
<binding key="F1" command="customHelp"/>
</bindings>
Regards,
Artur