Jump to content

Help - Simple Text File Editor


roccos34
 Share

Recommended Posts

Hi Guys, I'm not very expert in autoit, I need your help, I need to create a small script with GUI that allows me to modify a text file while still allowing line wrapping. Looking at the various codes on the forum I found one that was posted that could be useful for my purpose that I include in the post: the script will only have to modify one type of file which is the SQL Developer configuration file (this compiled script will be managed via the SCCM software catalog as the user does not have administrative rights to write to the file path). The script I found and which I managed to modify for my purpose works for inserting and deleting selected lines but I can't understand how to use the GUIListViewEx function to create a button that allows me to edit the selected line instead of just inserting and cancellation. If on this occasion you can give me some help to improve or correct errors in the script in addition to inserting the aforementioned function I would be grateful (translated with Google)

 

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <GUIMenu.au3>
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>

#include <WindowsConstants.au3>
#include 'Includes\GUIListViewEx.au3'
#include 'Includes\_GUICtrlListView_CreateArray.au3'
#include 'Includes\_GUICtrlListView_SaveTxt.au3'
#include 'Includes\_GUICtrlListView_SaveTxtEx.au3'

$PathFile = "C:\temp\sqldeveloper.conf"

; Simulate reading the file into an array
Global $aLines = ["Line1", "Line2", "Line3"]

If Not _FileReadToArray($PathFile, $aLines, 0) Then
   MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
EndIf

$hGUI = GUICreate("sqldeveloper.conf Configuration Tool", 900, 500)

$cLV = GUICtrlCreateListView(" ", 10, 10, 700, 300)
_GUICtrlListView_SetColumnWidth($cLV, 0, 890)

$cInsert = GUICtrlCreateButton("Insert Line", 800, 10, 80, 30)
$cDelete = GUICtrlCreateButton("Delete Line", 800, 50, 80, 30)
$cEdit = GUICtrlCreateButton("Edit", 800, 90, 80, 30)
$cSave = GUICtrlCreateButton("Save", 800,120, 80, 30)

GUISetState()

; Intialise ListView
$iLV_Index = _GUIListViewEx_Init($cLV)
; Insert lines
_GUIListViewEx_Insert($aLines, True)
; Register required messages
_GUIListViewEx_MsgRegister(True, False, False, False)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
         Case $cInsert
            $Entry = InputBox ("Inserire la linea","prompt")
            _GUIListViewEx_Insert($Entry)
         Case $cEdit


         ; necessary code ?

        Case $cDelete
            _GUIListViewEx_Delete()
        Case $cSave
                    $aExport = _GUICtrlListView_CreateArray($cLV, Default) ; Use | as the default delimeter.
                    _GUICtrlListView_SaveTxtEx($aExport, $PathFile)
    EndSwitch
WEnd

SimpleEditor.au3 sqldeveloper.conf

Edited by roccos34
Link to comment
Share on other sites

  • Moderators

roccos34,

Please read the forum rules - asking for help via PM is frowned upon here.

But as I am now here - take a look at the _GUIListViewEx_EditItem function. That allows you to edit an item within the ListView.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

roccos34,

Quote

but I can't make it work

Show the code you tried and we will see if we can get it working.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...