Jump to content

Installing an older version of AutoIT and SciTE breaks my code


Recommended Posts

Recently, I updated AutoIT to v3.3.12.0 and found that due to some of the SCRIPT BREAKER changes that broke too many of my scripts, I had to uninstall AutoIT and SciTE.  When I reinstalled AutoIT (3.3.10.2) and SciTE4AutoIT (14.801.2025.0), I somehow lost the hooks to run my private Lua scripts from the right click context menu.
 
I've been using my Lua scripts for a while before this so I know there's not a script error.
 
Here's how I added my Lua scripts:
  I copied these files from a local directory C:UsersAndy
   au3.properties
   PersonalTools.lua
   SciTEUser.properties
 
  The au3.properties file looks like this:
    # Add a _DebugOut statement that displays the hilighted
    # data or the word under the cursor like this:
    #   _DebugOut("+++: hilighted-text = " & hilighted-text)
    command.name.44.$(au3)=
    command.subsystem.44.$(au3)=3
    command.44.$(au3)=InvokeTool AutoItTools.addDebugOut
    command.save.before.44.$(au3)=2
  The PersonalTools.lua file looks like this:
-------------------------------------------------------------------------------
-- required line ... do not remove
PersonalTools = EventClass:new(Common)

--
-- Trap the OnStartup event
--    Create the user shortcut menu
--
--
-- Trap the OnOpen event
--    Call the createUserContextMenu() function to create a user
--    context menu tailored to the file type (lexor) of the file
--    being opened.
function PersonalTools:OnOpen()
    createUserContextMenu(self)
end

--
-- Create a user context menu tailored to the file type (lexer)
-- of the file being opened or switched to.
function createUserContextMenu(self)
    -- print(self:GetLexer())
    if self:IsLexer(SCLEX_AU3) then
            --print("AU3 lexer")
            props['user.context.menu'] = "|"
            .. "|add _DebugOut          | 1144"
    end
end

function PersonalTools:GetLexer(lexer)
    return editor.Lexer
end -- IsLexer()

--------------------------------------------------------------------------------
-- AutoItTools:addDebugOut()
--
-- Add a _DebugOut statement that displays the hilighted data or
-- the word under the cursor like this:
--   _DebugOut("+++: hilighted-text = " & hilighted-text)
--------------------------------------------------------------------------------
--
function AutoItTools:addDebugOut()
    local word = editor:GetSelText()

    if word == ""  or word == nil then
        word = self:GetWord()
    end
        
    if word ~= nil and word ~= "" then
        editor:LineEnd()
        editor:NewLine()
--                      _Debugout( "+++: word = " & word)
        editor:AddText('_Debugout( "+++: ' .. word .. ' = " & ' .. word .. ')')
    else
        print("The cursor not is not on any hilighted text.")
    end
end

I see my command when I right click on a word, but then nothing happens when I choose my command from the menu.

        
 
Link to comment
Share on other sites

  • Developers

Shouldn't this be like:

# Add a _DebugOut statement that displays the hilighted
    # data or the word under the cursor like this:
    #   _DebugOut("+++: hilighted-text = " & hilighted-text)
    command.name.44.$(au3)=
    command.subsystem.44.$(au3)=3
    command.44.$(au3)=InvokeTool PersonalTools.addDebugOut
    command.save.before.44.$(au3)=2

... and these changes shouldn't be made in au3.properties but in SciTEUser.properties

Jos

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

Link to comment
Share on other sites

OK, On my Windows XP PC, I completely uninstalled AutoIT and SciTE, then reinstalled AutoIt 3.3.12.0, and SciTE4AutoIT3.
 
I added this to the SciTEUser.properties file in C:Documents and SettingsAndy:
# Add a _DebugOut statement that displays the hilighted
    # data or the word under the cursor like this:
    #   _DebugOut("+++: hilighted-text = " & hilighted-text)
    command.name.44.$(au3)=
    command.subsystem.44.$(au3)=3
    command.44.$(au3)=InvokeTool PersonalTools.Demo
    command.save.before.44.$(au3)=2
I left the PersonalTools.lua file in C:Documents and SettingsAndy unchanged:
-- ==>LUA example file for personal LUA scripts.
-- ==>Copy this file to your %USERPROFILE% directory
-------------------------------------------------------------------------------
-- required line ... do not remove
PersonalTools = EventClass:new(Common)
-------------------------------------------------------------------------------

--------------------------------------------------------------------------------
-- demo() LUA script
-- to be able to use this script you add the following to your SciTEUSer.properties (without the leading "--"):
--#x lua test func
--command.name.41.$(au3)=Test
--command.mode.41.$(au3)=subsystem:lua,savebefore:no
--command.shortcut.41.$(au3)=Ctrl+Shift+F
--command.41.$(au3)=InvokeTool PersonalTools.Demo
--
--------------------------------------------------------------------------------
function PersonalTools:Demo()
    editor:BeginUndoAction()
    local FirstLine = editor:LineFromPosition(editor.SelectionStart)
    local LastLine = editor:LineFromPosition(editor.SelectionEnd)
    local CurrentLine = FirstLine
    editor:GotoLine(FirstLine)
    while (CurrentLine <= LastLine) do
        editor:Home()
        if CurrentLine == FirstLine then
            editor:AddText('$s = "' )
        else
            editor:AddText('\t\t"' )
        end
        editor:LineEnd()
        if CurrentLine == LastLine then
            editor:AddText('"' )
        else
            editor:AddText('" & @CRLF & _' )
        end
        CurrentLine = CurrentLine + 1
        editor:LineDown()
    end
    editor:EndUndoAction()
end
However, when I'm editing my .au3 file and I right click on a word, I get the standard copy/paste/cut menu.
 
I'm missing something here.

 

Link to comment
Share on other sites

  • Developers

Don't you need your version of personaltools.lua to make it work as that load the custom menu?

Did first try the suggested small change in your posted setup before trying anything else and did that not work?

Jos

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

Link to comment
Share on other sites

  • Jos: Don't you need your version of personaltools.lua to make it work as that load the custom menu?

Yes, as I detailed previously, I modified personaltools.lua in C:Documents and SettingsAndy

  • Jos: Did first try the suggested small change in your posted setup before trying anything else and did that not work?

With all of the installing and uninstalling, I was getting confused about what I did and when I did it. So I completely uninstalled AutoIT and Scite, then re-installed them to start with a fresh system.  So, with the personaltools.lua as the only thing I modified, I would expect it to work with the :Demo function, but it didn't show up in the right click context menu, and it wasn't in the Tools menu either.

 

There must be a hook that I'm missing.

Link to comment
Share on other sites

OK, I fixed it.  There are 3 files that need changes:

In my %SCITE_USERHOME% directory (C:UsersAndyAppDataLocalAutoIt v3SciTE)
 
SciTEUser.properties:
added:
import au3.UserUdfs
import au3.keywords.user.abbreviations
import au3
au3.properties:
added:
# Add a _DebugOut statement that displays the hilighted
# data or the word under the cursor like this:
#   _DebugOut("+++: hilighted-text = " & hilighted-text)
command.name.44.$(au3)=
command.subsystem.44.$(au3)=3
command.44.$(au3)=InvokeTool PersonalTools.addDebugOut
command.save.before.44.$(au3)=2
PersonalTools.lua:
added:
-------------------------------------------------------------------------------
-- required line ... do not remove
PersonalTools = EventClass:new(Common)

--
-- Trap the OnOpen event
--    Call the createUserContextMenu() function to create a user
--    context menu tailored to the file type (lexor) of the file
--    being opened.
function PersonalTools:OnOpen()
   createUserContextMenu(self)
end

--
-- Trap the OnSwitchFile event
--    Call the createUserContextMenu() function to create a user
--    context menu tailored to the file type (lexor) of the file
--    being switched to.
function PersonalTools:OnSwitchFile()
   createUserContextMenu(self)
end

--
-- Create a user context menu tailored to the file type (lexer)
-- of the file being opened or switched to.
function createUserContextMenu(self)
   props['user.context.menu'] = "|"
   .. "|add _DebugOut          | 1144"
end
--------------------------------------------------------------------------------
-- PersonalTools:addDebugOut()
--
-- Add a _DebugOut statement that displays the hilighted data or
-- the word under the cursor like this:
--   _DebugOut("+++: hilighted-text = " & hilighted-text)
--------------------------------------------------------------------------------
--
function PersonalTools:addDebugOut()
   local word = editor:GetSelText()


   if word == ""  or word == nil then
   word = self:GetWord()
   end

   if word ~= nil and word ~= "" then
      editor:LineEnd()
      editor:NewLine()
      --                     _Debugout( "+++: word = " & word)
      editor:AddText('_Debugout( "+++: ' .. word .. ' = " & ' .. word .. ')')
   else
      print("The cursor not is not on any hilighted text.")
   end
end

piece of cake  :)

Thank you for helping me solve this.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...