-- TIME_STAMP 2021-12-10 20:18:15 v 0.2 --[[ History v 0.3 added: Recognize that multiple words are highlighted. An attempt is made to select the applicable search term. changed: The property "SciteDefaultHome" is now used to select the AutoIt3 folder. Using the "autoit3dir" property can lead to incorrect results. v 0.2 added: Multiple UDF files for the same prefix i.e.: "udf.path._OL_=C:\Code\AutoIt\udf\OutlookEX 1.7.0.0\OutlookEX.au3|C:\Code\AutoIt\udf\OutlookEX 1.7.0.0\OutlookEX_Base.au3" changed: This script is now called from an executable *.au3 file. Therefore, the resulting command line for calling the respective help is passed to the calling program for execution. ]] local tAU3Help = {} do tAU3Help.pattFunc = '([Ff][Uu][Nn][Cc]%s+[%w_]+%s-%b())' tAU3Help.pattFuncName = '([Ff][Uu][Nn][Cc]%s+)([%w_]+)(%s-%b())' tAU3Help.t_names = {} tAU3Help.Split = function(self, _s, _delim) if not _s:find(_delim) then return {_s} end local t_res = {} for v in (_s.._delim):gmatch("(.-)".._delim) do table.insert(t_res, v) end return t_res end tAU3Help.GetItemHelp = function(self, _item) local match1, match2 if _item:find('%s') then match1, match2 = _item:match('([^%s]+)%s-([^%s]+)%b()') if not match2 then match1, match2 = _item:match('([^%s]+)%s-([^%s]+)') end if (match2 == nil or match2 == '') then if match1 ~= '' then match2 = match1 else match2 = '' end end _item = match2 end local prefix = _item:match('^(_%w+_)') if prefix ~= nil then if self:Extract(prefix) then if self.t_names[_item:upper()] then self:CallHelp(prefix, _item) return end end end self:CallHelp('AU3', _item) end tAU3Help.Extract = function(self, _prefix) self.t_names = {} local func, fname, err, s, a, e = '', '', 0 local t_udfpath = self:Split(props['udf.path.'.._prefix:upper()], '|') if #t_udfpath == 0 then return false end for i=1, #t_udfpath do local fh = io.open(t_udfpath[i]) if fh == nil then err = err + 1 else s = fh:read('*a') fh:close() e = 1 while e do a, e, func = s:find(self.pattFunc , e) if a then _, _, _, fname = func:find(self.pattFuncName) if fname:sub(1, _prefix:len()):upper() == _prefix:upper() then self.t_names[fname:upper()] = true end end end end end if err == #t_udfpath then return false end return true end tAU3Help.CallHelp = function(self, _prefix, _item) local path, cmd = props['chm.path.'.._prefix:upper()] if _prefix == 'AU3' then cmd = '"'..props['SciteDefaultHome']:sub(1,-7)..'\\Autoit3Help.exe" "'.._item..'"' else cmd = 'mk:@MSITStore:'..path..'::/funcs/'.._item..'.htm' end props['extender.result'] = cmd -- Runtime property, is queried by the calling Au3 script. end end tAU3Help:GetItemHelp(props['CurrentWord'])