Jump to content

Recommended Posts

Posted (edited)

Hey everyone!

Is there any way of having autoit read single lines (ie carriage return separated strings) from an edit box?

Thanks!

Example:

#include <GuiConstantsEx.au3>
#include <GuiEdit.au3>

$hGUI = GUICreate("Test", 300, 200)

$cEdit = GUICtrlCreateEdit("Line 1" & @CRLF, 10, 10, 280, 140)
GUICtrlSetData(-1, "Line 2" & @CRLF & _
               "Line 2" & @CRLF, 1)

$cButton_Get = GUICtrlCreateButton("Get", 11, 166, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton_Get
            $sText = _GUICtrlEdit_GetLineEx($cEdit)
            MsgBox(0, "Result", $sText)
    EndSwitch
WEnd

Func _GUICtrlEdit_GetLineEx($cControl)
    Local $aSel, $iLine
    
    $aSel = _GUICtrlEdit_GetSel($cControl)
    
    If $aSel[0] <> -1 Then
        $iLine = _GUICtrlEdit_LineFromChar($cControl, $aSel[0])
        Return _GUICtrlEdit_GetLine($cControl, $iLine)
    EndIf
EndFunc

Edit:

Said example returns the line of a string from current carret position. For returns any necessary line use the _GUICtrlEdit_GetLine function.

Edited by rasim
Posted

Hi Rasim!

Thanks for pointing out the _GUICtrlEdit_GetLine function. I think that works exactly like a file read line function when put into a loop? What I want my GUI to do is to read a single line from the edit box, apply a transformation, output to text file, and repeat for every single line of code. I got stuck on the 'read a single line". :)

Thanks again!

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
×
×
  • Create New...