Jump to content

Help with Edit Box


Recommended Posts

I'm basicly trying to make it to where when I press "$Button2", it loads the text "Hi" into the $edit1 edit box. I've been reading the help file for a while, I couldnt figure it out.

Any help is appreciated. Thanks.

#include <GUIConstants.au3>
#include <funktions.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\AForm1.kxf
$Form1_1 = GUICreate("Custom Skills", 217, 211, 322, 204)
$edit1 = GUICtrlCreateEdit("", 8, 8, 121, 193, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Save", 136, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Load", 136, 72, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Help", 136, 104, 75, 25, 0)
$Button4 = GUICtrlCreateButton("OK", 136, 8, 75, 25, 0)
$Button5 = GUICtrlCreateButton("Cancel", 136, 176, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2 
        $edit1 = ("hi")
    EndSwitch
WEnd
Link to comment
Share on other sites

you could edit this to match your button

CODE
GUISetState()

While 1

$cursorinfo = GUIGetCursorInfo($window)

If $cursorinfo[4] = $Edit1 Then

If $cursorinfo[2] = 1 Then

GUICtrlSetData($Edit1, "")

EndIf

EndIf

WEnd

Link to comment
Share on other sites

I'm basicly trying to make it to where when I press "$Button2", it loads the text "Hi" into the $edit1 edit box. I've been reading the help file for a while, I couldnt figure it out.

Any help is appreciated. Thanks.

#include <GUIConstants.au3>
#include <funktions.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\AForm1.kxf
$Form1_1 = GUICreate("Custom Skills", 217, 211, 322, 204)
$edit1 = GUICtrlCreateEdit("", 8, 8, 121, 193, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Save", 136, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Load", 136, 72, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Help", 136, 104, 75, 25, 0)
$Button4 = GUICtrlCreateButton("OK", 136, 8, 75, 25, 0)
$Button5 = GUICtrlCreateButton("Cancel", 136, 176, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2 
        $edit1 = ("hi")
    EndSwitch
WEnd
Try this...

#include <GUIConstants.au3>
#include <funktions.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\AForm1.kxf
$Form1_1 = GUICreate("Custom Skills", 217, 211, 322, 204)
$edit1 = GUICtrlCreateEdit("", 8, 8, 121, 193, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Save", 136, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Load", 136, 72, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Help", 136, 104, 75, 25, 0)
$Button4 = GUICtrlCreateButton("OK", 136, 8, 75, 25, 0)
$Button5 = GUICtrlCreateButton("Cancel", 136, 176, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Select    
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $Button2 
            GUICtrlSetData($edit1, "Hi")
    EndSelect
WEnd

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

Moving too slow today I suppose... and making things more complicated. :)

Edited by ksmith247

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

Alright, so I got that to work, but the problem is, I'm wanting it to load everything thats inside a .ini file. And its only listening one line of it... I want it to load every line in the .ini file one by one like it was a list, only its an edit box instead...

Heres the main "Script":

#include <GUIConstants.au3>
#include <funktions.au3>

#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\AForm1.kxf
$Form1_1 = GUICreate("Custom Skills", 217, 211, 322, 204)
$edit1 = GUICtrlCreateEdit("", 8, 8, 121, 193, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$Button1 = GUICtrlCreateButton("Save", 136, 40, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Load", 136, 72, 75, 25, 0)
$Button3 = GUICtrlCreateButton("Help", 136, 104, 75, 25, 0)
$Button4 = GUICtrlCreateButton("OK", 136, 8, 75, 25, 0)
$Button5 = GUICtrlCreateButton("Cancel", 136, 176, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2 
            Execute(loadini1())
    EndSwitch
WEnd

Heres the "Loadini1()" function:

#include <GUIConstants.au3>
Func loadini1()
    $file = FileOpen("customskills.ini", 0)
; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Make sure customskills.ini is in the same directory as Bot.exe.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    GuiCtrlSetData($edit1,$line) 
Wend
;FileClose($file)
EndFunc

Thanks again.

Link to comment
Share on other sites

What about

Case $Button2

loadini1()

(trying to beat weaponx to the punch)

Support bacteria; it's the only culture most people have.LxP's Learning to Script with AutoIt 3 - Excellent starting placeVolly's Links Page - Links to cool and useful scriptsAutoIt Wrappers - Valuater's AutoIt Wrappers post. Lots of good stuff.Support AutoIt - Make a donation here; I did.[size="2"]#include <Guinness.pint>[/size]

Link to comment
Share on other sites

It will NEVER work using FileOpen() on the ini file

Instead use

IniReadSectionNames() ;; Returns an array of the section names

and

IniReadSection() ;; This will return a two dimension array with the Key and Value

Edit:

You might also want to take a look at the INI UDF I posted in Example Scripts yesterday for Ini functions and examples of hou to use the arrays I mentioned above.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

It will NEVER work using FileOpen() on the ini file

Instead use

IniReadSectionNames() ;; Returns an array of the section names

and

IniReadSection() ;; This will return a two dimension array with the Key and Value

^Yeah, thats what I was using before all of this, the problem is, I dont want it to read the Keys. I was trying to get it to read everything under the [sectionName], but I just couldnt figure it out. Like say my .ini looks like:

-----------------

[sectionHere]

blah1

blah2

blah3

blah4

----------------

Could you give an example on how to make that appear in a edit box like this:

-------------

blah1

blah2

blah3

blah4

-------------

Thanks.

Link to comment
Share on other sites

well inis have keys so make your ini

[section]

0 = blah

1 = blah

2 = blah

Global $var
$var =  IniReadsection ("name", "section")

Returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.

Edited by sccrstvn93
Link to comment
Share on other sites

^Yeah, thats what I was using before all of this, the problem is, I dont want it to read the Keys. I was trying to get it to read everything under the [sectionName], but I just couldnt figure it out. Like say my .ini looks like:

-----------------

[sectionHere]

blah1

blah2

blah3

blah4

----------------

Could you give an example on how to make that appear in a edit box like this:

-------------

blah1

blah2

blah3

blah4

-------------

Thanks.

$I_Sec = INIReadSection($Ini, $Section)
$Out = ''
For $I = 1 To $I_Sec [0][0]
 $Out &= $I_Sec[$I][0] & @CR
Next
GUICtrlSetData($Ctrl, StringTrimRight($Out, 1))

Look at the UDF I mentioned

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

well inis have keys so make your ini

[section]

0 = blah

1 = blah

2 = blah

Global $var
$var =  IniReadsection ("name", "section")

Returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.

Yeah, but I'm trying to make something like a "Script Editor" so whoever is using it can add theyre own code. I mean I dont want them to have to write:

[section]

0 = Send {"R"}

1 = Sleep (300)

2 = Sleep (500)

So basicly I just want it to be like a simple notepad.

Thanks.

Link to comment
Share on other sites

If anyone has any example scripts of a custom-made notepad/script editor or something like that, that would help alot also.

Thanks again for all your help. I'm gonna keep trying to figure this out.

Link to comment
Share on other sites

If anyone has any example scripts of a custom-made notepad/script editor or something like that, that would help alot also.

Thanks again for all your help. I'm gonna keep trying to figure this out.

Search Example Scripts. There used to be a couple around

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

you could have them enter there code into notepad and then use filereadline and then have your script automatically create an ini form what they enter.

FileReadLine is very slow. Better method is to read it to an array and then work with that. Each FileReadLine starts at the top of the script again to get the line. It's ok for 1 or 2 lines but after that it's not much good unless you know the specific line number to read.

For instance if you wanted to read lines 2, 16 and 42

It starts at the top and moves to line 2

It returns to the top and then moves down to read line 16

It returns to the top and then moves down to line 42

It doesn't go to 2 then jump to 16 and then to 42.

So you can see that it's going to be slow even if you put it in a loop

For $I = 1 To 10
  $Out = FileReadLine($File, $I)
Next

Will read the first 10 lines using the same method as above.

Reading it to an array it will just jump straight to the correct element number

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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