Jump to content

Read Edit?


Recommended Posts

How do I want to read single Edit Box?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 335, 277, 286, 159)
$Button1 = GUICtrlCreateButton("Read Line", 120, 192, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 56, 24, 201, 121)
GUICtrlSetData($Edit1, "First line" & @CRLF & _
                       "Second line" & @CRLF & _
                       "Third line")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
             $read = GUICtrlRead($Edit1)
For $i = 1 To $read 0 Step 1
    MsgBox (0, 0,$i)
Next

    EndSwitch
WEnd

 

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 335, 277, 286, 159)
Global $Button1 = GUICtrlCreateButton("Read Line", 120, 192, 75, 25)
Global $Edit1 = GUICtrlCreateEdit("First line" & @CRLF & "Second line" & @CRLF & "Third line", 56, 24, 201, 121)
Global $inpLine = GUICtrlCreateInput(1, 200, 192, 50, 20, $ES_NUMBER)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While (True)
    Switch (GUIGetMsg())
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            MsgBox("", "", GUICtrlEditReadLine($Edit1, GUICtrlRead($inpLine)))
    EndSwitch
WEnd

Func GUICtrlEditReadLine($iCtrId, $iLine)
    Local $sText = GUICtrlRead($iCtrId)
    Local $aText = StringSplit(StringReplace($sText, @CR, ""), @LF)

    If (IsArray($aText)) Then
        If ($iLine >= 1 and $iLine <= $aText[0]) Then Return $aText[$iLine]
    EndIf
    Return SetError(1, 0, "")
EndFunc   ;==>GUICtrlEditReadLine

 

Link to comment
Share on other sites

Maybe more simple and easy to understand:

#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 335, 277, 286, 159)
$Button1 = GUICtrlCreateButton("Read Line", 120, 192, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 56, 24, 201, 121)
GUICtrlSetData($Edit1, "First line" & @CRLF & _
                       "Second line" & @CRLF & _
                       "Third line")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $nMsg = $Button1 Then
        MsgBox("", "Edit Box", GUICtrlRead($Edit1))
    EndIf
WEnd

Regards
Alien.

Link to comment
Share on other sites

Or:

#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Hello AutoIt", 336, 278, -1, -1)
Global $Button1 = GUICtrlCreateButton("Read Line", 216, 8, 107, 73)
Global $Edit1 = GUICtrlCreateEdit("", 8, 8, 201, 265)
GUICtrlSetData($Edit1, "First line" & @CRLF & _
        "Second line" & @CRLF & _
        "Third line")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case -3
            Exit

        Case $Button1
            Local $read = GUICtrlRead($Edit1)
            Local $sLine = StringSplit(StringReplace($read, @CR, ""), @LF)
            For $i = 1 To UBound($sLine) - 1
                MsgBox(32, "Line " & $i, $sLine[$i], Default, $Form1)
            Next

    EndSwitch
WEnd

 

Edited by Trong
DeclareVars

Regards,
 

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