Jump to content
Sign in to follow this  
fspafford

Format used by AutoItTools:ExportLibrary()?

Recommended Posts

fspafford

I looked at the description of AutoItTools:ExportLibrary() and added it to my Tools menu, but I can't seem to make it work. Perhaps the format of my UDF headers is wrong. Can anyone give a short sample that shows the format required?

I currently get the following lines (I added the region):

#Region Members Exported
#cs Exported Functions
#ce Exported Functions
#endregion

Thanks,

Frank


Frank

Share this post


Link to post
Share on other sites
0xdefea7

Googling this: AutoItTools:ExportLibrary() does not come up with much, can you please elaborate on what you are talking about? Possibly post the link that you are referring to where the description is at.

Share this post


Link to post
Share on other sites
fspafford

ExportLibrary() is a routine included in the LUA file typically installed with AutoIt at:

C:Program Files (x86)AutoIt3SciTELUAAutoItTools.lua

The routines in the file can be added to the Tools menu in the AutoIt editor. (Some are there already.)

Frank


Frank

Share this post


Link to post
Share on other sites
0xdefea7

Looks like you have it right as far as your headers goes:

function AutoItTools:ExportLibrary()
    -- These are constants used throughout.
    local region_text = "#Region Members Exported"
    local comment_start = "#cs Exported Functions"
    local comment_end = "#ce Exported Functions"

That is from the LUA file. It first checks for the region, then then comment_start, then reads to comment_end - written just like you have it.

Share this post


Link to post
Share on other sites
Jos

The delivered LUA scripts and au3.properties should give you ample examples on how to trigger a LUA function from SciTE.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
fspafford

I have been successful in triggering a few LUA functions from the Tools menu of SciTE, but that is not where I have a question. Sorry for the confusion, and thanks for AutoIt!

Currently, I have added the LUA routine AutoItTools:ExportLibrary() to the Tools menu (source file C:Program Files (x86)AutoIt3SciTELUAAutoItTools.lua), but when I run the tool, I don't see any routines added to the #Region Members Exported region. I looked at the LUA script, and I suspect my routines are missing some type of formatting required by the regular expression in ExportLibrary().

The LUA code is:

--------------------------------------------------------------------------------
-- ExportLibrary()
--
-- Creates an exports section in an AutoIt file containing comments describing
--     the functions in the file.
--
-- Tool: AutoItTools.ExportLibrary $(au3) savebefore:no,groupundo:yes Ctrl+Alt+E Export Library
--------------------------------------------------------------------------------
function AutoItTools:ExportLibrary()
    -- These are constants used throughout.
    local region_text = "#Region Members Exported"
    local comment_start = "#cs Exported Functions"
    local comment_end = "#ce Exported Functions"
    local nl = self:NewLineInUse()

    -- We work over the entire document.
    local doc = editor:GetText()
    if not doc:find(region_text, 1, true) then
        print("Error: Unable to find "" .. region_text .. "" in the library, no export list created.")
    else
        local from, to, found = false
        if not doc:find(comment_start, 1, true) then
            print("Warning: Unable to find "" .. comment_start .. "" in the library, there may be multiple export lists.")
            from = doc:match(region_text .. nl .. "()")
            to = from
        else
            from = doc:match(comment_start .. nl .. "()")
            to = doc:match("()" .. comment_end)
            found = true
        end
        -- This should never happen due to the checks above.
        if not from or not to then
            print("Error, unable to determine where to add the export list.")
        else
            -- Store the list in this variable.
            local text = ""
            -- We only build the list for functions we can find in the code.
            -- Orphaned comments will not be found.
            for pos, str in doc:gmatch(self.Pattern) do
                -- Pull the name out of string so we can build a pattern.
                local name = str:match("^(.-)[%(%s]")
                -- First check that the name doesn't start with __ which means
                -- it's private.
                if not str:find("^__") then
                    -- Build the pattern.  It's a bit complicated to keep it
                    -- from running over lines it shoudn't.
                    local pattern = ";%s+(" .. name .. "%s*%([^" .. nl .. "]+)" .. nl .. ";%s+;(.-);%s+Parameters"
                    -- Get the two parts.
                    local func, desc = doc:match(pattern)
                    -- Ensure they are valid.
                    if func and desc then
                        -- Clean up the text, put on a single line, remove trailing spaces.
                        func = func:gsub("%s*$", "")    -- Trailing spaces
                        desc = desc:gsub("%s*;%s*", " ")    -- Multiple lines
                        desc = desc:gsub("^%s*", "")    -- Leading spaces
                        desc = desc:gsub("%s*$", "")    -- Trailing spaces
                        -- Concatenate the formatted text.
                        text = text .. func .. " - " .. desc .. nl
                    end
                end
            end
            -- We have to offset our indices because SciTE is 0-based while Lua
            -- strings are 1-based.
            editor:SetSel(from - 1, to -1)
            -- If the exports section already exists, we are replacing it.
            if found then
                editor:ReplaceSel(text)
            -- Otherwise, we have to insert the exports section.
            else
                editor:ReplaceSel(comment_start .. nl .. text .. comment_end .. nl)
            end
            print("Exports list created. ")
        end
    end
end    -- ExportLibrary()

Frank
 


Frank

Share this post


Link to post
Share on other sites
fspafford

I looked at the description of AutoItTools:ExportLibrary() and added it to my Tools menu, but I can't seem to make it work. Perhaps the format of my UDF headers is wrong. Can anyone give a short sample that shows the format required?

I currently get the following lines (I added the region):

#Region Members Exported
#cs Exported Functions
#ce Exported Functions
#endregion

Thanks,

Frank


Frank

Share this post


Link to post
Share on other sites
Melba23

fspafford,

As you already have a thread running on this, why not stick with it. Threads merged. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
fspafford

I am still looking for an answer - mainly what is needed to match this pattern from the Lua code above:

   local pattern = ";%s+(" .. name .. "%s*%([^" .. nl .. "]+)" .. nl .. ";%s+;(.-);%s+Parameters"


Frank

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • BugFix
      By BugFix
      This lua script gives you the ability, to search for selected text or word from cursor in an search engine or on an search site of your choice.You can select the engine/site from a list, that you have defined in your user properties.
      To get the right call for your search engine, open the engine and search for one word. You need the url without the searched word. Write to your properties an display name for this engine and, separated by a comma, the url. See my example in the script header.
      For the list with  search sites, you need display name and site address (without http://).
      It will searched for the full selected text or, if none selection exists, for the word touched by the cursor. You can allow in the properties, that also will recognized words with dots (like objVar.Property).
      The script uses the shell.dll. But if you don't have installed it, the browser will opened with an command line call. Thats why the command window will pop up for a short moment.
      You'll find details for installation and key bindings inside the script. Look for free command numbers in SciTE. By default installation, the numbers must be greater than 35 (max. 49).
      -- TIME_STAMP 2018-09-02 09:22:03 --[[ This script publicates two functions - InetSearch.Engine() You can search for the selected/touched text in SciTE and can select a search engine of your choice. - InetSearch.Site() You can search for the selected/touched text in SciTE with a defined search engine and can select a search site of your choice. Copy this script in your Lua scripts folder. Load this file in the Lua startup: dofile("Full\\Path\\InetSearch.lua") Add in "SciTEUser.properties" the following properties with search engines and search sites of your choice: #~ Inet Search Settings #~ List of engines. "display-name,search-url" (if not set: google.com will used) #~ If only one entry exists, the selection box will not shown. Inet.Search.Engines= \ Google,https://www.google.de/search?q=| \ MetaGer,https://metager.de/meta/meta.ger3?focus=web&eingabe=| \ Bing,https://www.bing.com/search?q=| \ Ask,https://de.ask.com/web?q=| \ Yandex,https://www.yandex.com/search/?text= #~ Engine for site based search #~ Use display name from engines list (if not set: google.com will used) Inet.Search.SearchOnSite.Engine=Google #~ List of sites for site based search. "display-name,site-url" #~ If not set, it searches without a special site. #~ If only one entry exists, the selection box will not shown. Inet.Search.SearchOnSite.Sites= \ AutoIt DE,autoit.de| \ AutoIt EN,autoitscript.com| \ MSDN,msdn.microsoft.com #~ By default, words will detected without dots. (0) #~ You can allow dots, to detect object variables with properties or methods too. Inet.Search.Allow.Punctuation=1 #~ Search commands #~ Search word from cursor with engine selection command.name.9.*=Search with engine selection command.9.*=dostring InetSearch.Engine() command.mode.9.*=subsystem:lua,savebefore:no command.shortcut.9.*=Ctrl+Shift+F8 #~ Search word from cursor with search site selection command.name.5.*=Search with site selection command.5.*=dostring InetSearch.Site() command.mode.5.*=subsystem:lua,savebefore:no command.shortcut.5.*=Ctrl+Shift+F9 --]] InetSearch = {} InetSearch.Handler = EventClass:new(Common) do ------------------------------------------------------------------------------------------------ local engineFallback = "Google,https://www.google.com/search?q=" -- default search engine: "display-name,search-url" local search_type = nil local engine_url = nil local search_item = nil local search_site = nil local tableSelection = nil local list_type = 16 ------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------- Load library protected local require_protected = function(_lib) local loaded_lib if pcall(function() loaded_lib = require(_lib) end) then return loaded_lib else return nil end end --> require_protected ------------------------------------------------------------------------------------------------ local shell = require_protected("shell") -- loads the shell library if exists ------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Starts the search local RunSearch = function(_item, _url, _site) local sSite = '' if _site ~= nil then sSite = "%20site:".._site end local sCmd = _url.._item..sSite if shell then shell.exec(sCmd) else os.execute('start "" "'..sCmd..'"') end end --> RunSearch ------------------------------------------------------------------------------------------------ ----------------------------------------------------------------------------- Show the user list local ShowSelectionList = function() -- create the selection list (display names from engines or sites) local sep, list = '_', tableSelection[1][1] for i = 2, #tableSelection do list = list..sep..tableSelection[i][1] end local sep_tmp = editor.AutoCSeparator editor.AutoCSeparator = string.byte(sep) editor:UserListShow(list_type, list) editor.AutoCSeparator = sep_tmp end --> ShowSelectionList ------------------------------------------------------------------------------------------------ --------------------------------------------------------------------------- Select the user list function InetSearch.Handler:OnUserListSelection(_tp, _sel) if _tp == list_type then local url for i = 1, #tableSelection do if tableSelection[i][1] == _sel then url = tableSelection[i][2] break end end if search_type == 'site' then search_site = url else search_site = nil engine_url = url end RunSearch(search_item, engine_url, search_site) end end ------------------------------------------------------------------------------------------------ --------------------------------------------------------- List of search engines from properties local GetEngines = function() local sEngines = props['Inet.Search.Engines'] -- without settings, the default search engine will used if sEngines == '' then sEngines = engineFallback end local tEngines = {} for entry in sEngines:gmatch('([^|]+)|-') do for name, url in entry:gmatch('([^,]+),(.+)') do table.insert(tEngines, {name, url}) end end return tEngines end --> GetEngines ------------------------------------------------------------------------------------------------ ----------------------------------------------------------- List of search sites from properties local GetSearchSites = function() local sSites = props['Inet.Search.SearchOnSite.Sites'] if sSites == '' then return nil end local tSites = {} for entry in sSites:gmatch('([^|]+)|-') do for name, url in entry:gmatch('([^,]+),(.+)') do table.insert(tSites, {name, url}) end end return tSites end --> GetSearchSites ------------------------------------------------------------------------------------------------ -------------------------------------------------------------------------------- Get search item local GetSearchItem = function() local sSelect = editor:GetSelText() if sSelect ~= '' then return sSelect end local allowDots = false if props['Inet.Search.Allow.Punctuation'] == '1' then allowDots = true end local caret = editor.CurrentPos local iLine = editor:LineFromPosition(caret) local iZero = editor:PositionFromLine(iLine) editor:LineEnd() local iLineEnd = editor.CurrentPos editor.CurrentPos = caret editor:SetSelection(caret,caret) local iStart = editor:WordStartPosition(caret) if allowDots then while iStart > iZero and editor:textrange(iStart -1, iStart) == '.' do iStart = editor:WordStartPosition(iStart -1) end end local iEnd = editor:WordEndPosition(caret) if allowDots then while iEnd < iLineEnd and editor:textrange(iEnd, iEnd +1) == '.' do iEnd = editor:WordEndPosition(iEnd +1) end end sSelect = editor:textrange(iStart, iEnd):gsub('^([^%w]+)', ''):gsub('([^%w]+)$', '') return sSelect end --> GetSearchItem ------------------------------------------------------------------------------------------------ ------------------------------------------------------------------- Search with engine selection local SearchEngineBased = function() search_type = 'engine' search_item = GetSearchItem() if search_item == '' then return nil end tableSelection = GetEngines() -- only one entry: selection box will not shown if #tableSelection == 1 then RunSearch(search_item, tableSelection[1][2], nil) else ShowSelectionList() end end --> SearchEngineBased ------------------------------------------------------------------------------------------------ -------------------------------------------------------------- Search with search site selection local SearchSiteBased = function() search_type = 'site' search_item = GetSearchItem() if search_item == '' then return nil end -- get the default engine for site based searching for _, url in engineFallback:gmatch('([^,]+),(.+)') do engine_url = url end -- if is set, use search engine from properties local sEngine = props['Inet.Search.SearchOnSite.Engine'] if sEngine ~= '' then local tEngines = GetEngines() for i = 1, #tEngines do if tEngines[i][1] == sEngine then engine_url = tEngines[i][2] break end end end tableSelection = GetSearchSites() -- if none entries for search sites, use simple search if tableSelection == nil then RunSearch(search_item, engine_url, nil) else -- only one entry: selection box will not shown if #tableSelection == 1 then RunSearch(search_item, engine_url, tableSelection[1][2]) else ShowSelectionList() end end end --> SearchSiteBased ------------------------------------------------------------------------------------------------ ---------------------------------------------------------------------------- Publicate functions InetSearch.Engine = SearchEngineBased InetSearch.Site = SearchSiteBased ------------------------------------------------------------------------------------------------ end ----------------------------------------------------------------------------------------------------  
      InetSearch.lua
    • jaberwacky
      By jaberwacky
      When ever you hover your mouse over a native function, user defined function, or an AutoItObject method then you will see the calltip for that function. 
      Click "Like This" if you found this useful!

      To use this just place the following lua file in the "...AutoIt3SciTELUA" directory. 
      MouseHoverCalltips.zip
      downloads:216
      After you have done that then open SciTE and click 'Options' --> 'Open Lua Startup Script' and paste this line after the other lines (may require administrative rights):
      LoadLuaFile("MouseHoverCallTips.lua") Updates and changes:


    • mLipok
      By mLipok
      I looked at ScriptControl.
      I wonder if using this, can I do IPC solution in AutoIt. I also wonder whether some extent, ScirptControl can be compared to the use of LUA.  
      Below is what I have read so far.
      http://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx
      http://support.microsoft.com/kb/184739/EN-US
      http://msdn.microsoft.com/en-us/library/aa227413(v=vs.60).aspx
      http://www.microsoft.com/en-us/download/details.aspx?id=1949
      '?do=embed' frameborder='0' data-embedContent>>
      '?do=embed' frameborder='0' data-embedContent>>
      '?do=embed' frameborder='0' data-embedContent>>
       
      btw.
      Please, share with other interesting links that according to you is worth reading on the subject (links not directly related to the AutoIt).
    • mLipok
      By mLipok
      With reference to

      I found an intresting SciTE console example
      https://code.google.com/p/scite-for-lua/
      '>
       
      Does SciTE using ConsoleWrite is possible to display the message in the console with backlight as it is shown in the example.   If it is not currently possible, and taking into account that it was hard to develop a beta version of AutoIT is it possible to add such functionality?    
    • JoshuaBarnette
      By JoshuaBarnette
      I need to elevate certain applications, when launched, to run with an elevated (administrator level) security token. The token swap can happen on the fly or as an application wrapper.

      I have looked at several applications and find them ok, one even stands out above the rest, however my company is in extreme cost savings and are unable/unwilling to spend the money.

      I have seen Functions such as _Security__CreateProcessWithToken and _Security__AdjustTokenPrivileges, but I am still relatively new to AutoIT and am not sure how to utilize some of the advanced features.

      I appreciate any help.

      Thanks,
      Joshua Barnette
×