Sign in to follow this  
Followers 0
hahn

Total newbie need start help with edit line using menu box

5 posts in this topic

Hi in here.

Ya i am not a programmer and i have to start from the beginning using this autoit but I am looking for a way to edit a line in notepad.

If I have a notepad saying

From line 1 to 121 is some standard default script to maybe cisco or anything and then in:

Line 122 name xxxxxxx

Line 123 ip address xxxxxxxx

Line 124 something more

Is there a simple way to do this:

Wind I click open an autoit program I will get an box with 4 files say:

Inset name:

Inset IP

Inset port

Inset vlan

Then a butten there say crate.

This will open a notepad inset name in line 122, ip in 123 and so on and after this it will save the notepad under the name it has inset in line 122?

I think this have to be made before in time, but if not is there any out there thad have an idar to this?

I have try with notepad2 from autoit install and put the default in there, to start the notepad, but I am sure there is a better way?

Hope someone can help me here.....

Cheers

      Jimmy

Share this post


Link to post
Share on other sites



#3 ·  Posted

Is there any there are up fore a little job to this plz pm me.

 

cheers jimmy

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hello Jimmy,

Here is something i did fast to give you an idea on how to do what you want:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <File.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 739, 614, 561, 191)
$Label1 = GUICtrlCreateLabel("Configuration editor", 208, 24, 325, 41)
GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("File to edit:", 32, 160, 94, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("Input1", 152, 160, 425, 21)
$Browse = GUICtrlCreateButton("Browse", 608, 160, 105, 25)
$Label3 = GUICtrlCreateLabel("Name", 48, 232, 50, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("IP address", 32, 304, 90, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Port", 56, 376, 37, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("VLAN", 48, 440, 50, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("Input1", 152, 232, 425, 21)
$Input3 = GUICtrlCreateInput("Input1", 152, 304, 425, 21)
$Input4 = GUICtrlCreateInput("Input1", 152, 376, 425, 21)
$Input5 = GUICtrlCreateInput("Input1", 152, 440, 425, 21)
$Button2 = GUICtrlCreateButton("Beam me up Scotty!", 240, 528, 201, 65)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Browse
            $result = FileOpenDialog("Select file to open","C:\", "All (*.*)")
            GUICtrlSetData($Input1, $result)
        Case $Button2
            $file = ""
            _FileReadToArray(GUICtrlRead($Input1), $file)
            $file[122] = GUICtrlRead($Input2)
            $file[123] = GUICtrlRead($Input3)
            $file[124] = GUICtrlRead($Input4)
            $file[125] = GUICtrlRead($Input5)
            _ArrayDelete($file, 0)
            $file_name_lenght = StringLen(Guictrlread($Input1))
            $file_delimitor = stringinstr(GUICtrlRead($Input1), "\", 0, -1)
            $file_folder = $file_name_lenght - $file_delimitor
            $file_new_name = StringTrimRight(GUICtrlRead($Input1), $file_folder)
            _FileWriteFromArray($file_new_name & GUICtrlRead($Input2) & ".txt", $file)
            msgbox("","Enterprise to bridge", "Aye aye captain!")
    EndSwitch
WEnd

This will only work if the file you select has 125 lines or more :)

I did not include any checkup to see if anything selected / written is correct so it might fail if not used correctly. I let you figure out how to do this so you work a bit on it at least ;)

Enjoy :)

Edited by Neutro

Share this post


Link to post
Share on other sites

#5 ·  Posted

THX For PM m8 and ya this is a rely good job.

 

Cheers

     Jimmy

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  
Followers 0