Markierten Text aus der Edit

  • Hallo zusammen,

    eine Frage: Wie kann ich den markierten Text aus dem Editfenster auslesen.
    Hier mein Mustercode:

    Spoiler anzeigen
    [autoit]

    #include <GuiConstants.au3>

    Local $qst = GUICreate("Muster", 800, 502, -1, -1, BitOR($WS_SYSMENU, $WS_MINIMIZEBOX))

    [/autoit] [autoit][/autoit] [autoit]

    $EditLOGFile = GUICtrlCreateEdit("", 1, 1, 792, 470, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
    GUICtrlSetData ( $EditLOGFile, 'Das ist mein Beispieltext.')
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
    Ende()
    EndIf
    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func Ende()
    Exit
    EndFunc ;==>Ende

    [/autoit]


    Für jede Hilfe bin ich dankbar!

  • @pee damit ließt er ja den ganzen text aus feld aus...ich dachte er will nur den text den er markiert hat.....

    was willst du denn damit anfangen vll gibt es eine besser möglichkeit das zu lösen...


    snoxat0r

  • Hi,

    damit lese ich den gesamten Text, nicht nur die Markierung.
    Ich möchte nur den String der markiert ist auslesen um diesen dann weiter zu bearbeiten.

    Einmal editiert, zuletzt von xoma (13. Juli 2007 um 10:58)

    • Offizieller Beitrag

    Sorry, hatte ich überlesen! Aus der Hilfe:

    [autoit]

    #include

    [/autoit] #include [autoit] opt('MustDeclareVars', 1) Dim $myedit, $Status, $msg, $Btn_GET, $a_sel GUICreate("Edit Get Line Count", 392, 254) $myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE)) GUICtrlSetLimit($myedit, 1500) $Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER)) $Btn_GET = GUICtrlCreateButton("Get Sel", 150, 130, 90, 40, $BS_MULTILINE) ; will be append dont' forget 3rd parameter GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _ "5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1) GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Btn_GET $a_sel = _GUICtrlEditGetSel ($myedit) If ($a_sel == $EC_ERR) Then GUICtrlSetData($Status, "Error getting sel positions") ElseIf (IsArray($a_sel)) Then GUICtrlSetData($Status, "Starting Pos: " & $a_sel[1] & " Ending Pos: " & $a_sel[2]) Else GUICtrlSetData($Status, "") EndIf EndSelect WEnd[/autoit]
    peethebee
  • Hi,

    ich stehe jetzt auf dem Schlauch und blicke nichts mehr durch. ?(
    Mit dem Beispiel sehe ich wo die Markierung anfäng und wo die aufhört.
    Aber wie bekomme ich den markierten Text in die Variable ?(

    • Offizieller Beitrag

    Hi,

    hier ist auch noch ne Funktion, die du evtl. gebrauchen könntest.

    Spoiler anzeigen
    [autoit]

    #Include <GuiEdit.au3>
    #include <GUIConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered
    $myedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))

    [/autoit] [autoit][/autoit] [autoit]

    $b = GUICtrlCreateButton("ok", 10, 160, 40, 20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    ; will be append dont' forget 3rd parameter
    GUICtrlSetData($myedit, "Second line" & @CRLF & " Hallo", 1)

    [/autoit] [autoit][/autoit] [autoit]

    ; Run the GUI until the dialog is closed
    While 1
    $msg = GUIGetMsg()

    [/autoit] [autoit][/autoit] [autoit]

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $b Then _GUICtrlEditTextClipboard($myedit, "Cut")
    WEnd
    Func _GUICtrlEditTextClipboard($Edit, $type = "Copy")
    $a_sel = _GUICtrlEditGetSel($Edit)
    If ($a_sel == $EC_ERR) Then
    Return 2 ;Error Getting Selection Pos
    EndIf
    Local $WholeEdit = GUICtrlRead($Edit)
    Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1])
    If $type = "Copy" Then
    ClipPut($Trim)
    Return 0 ;Sucsessful Copy
    ElseIf $type = "Cut" Then
    ClipPut($Trim)
    _GUICtrlEditReplaceSel($Edit, 1, "")
    Return 1 ;Sucsessful Cut
    Else
    Return 3 ; Error with type of clipboard
    EndIf
    EndFunc ;==>_GUICtrlEditTextClipboard

    [/autoit]

    So long,

    Mega

    • Offizieller Beitrag

    Hallo xoma!

    Hier mal die Version von peethebee in dein Beispiel eingebaut.


    Spoiler anzeigen
    [autoit]


    #include <GuiConstants.au3>
    #include <GuiEdit.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Dim $myedit, $Status, $msg, $Btn_GET, $a_sel, $search

    Local $qst = GUICreate("Muster", 800, 502, -1, -1, BitOR($WS_SYSMENU, $WS_MINIMIZEBOX))

    $EditLOGFile = GUICtrlCreateEdit("", 1, 1, 792, 270, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
    GUICtrlSetData ( $EditLOGFile, 'Das ist mein Beispieltext.')
    $Btn_GET = GUICtrlCreateButton("Get Sel", 150, 300, 90, 40, $BS_MULTILINE)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Ende()
    Case $msg = $Btn_GET
    $a_sel = _GUICtrlEditGetSel($EditLOGFile)
    If ($a_sel == $EC_ERR) Then
    MsgBox(0, "", "Fehler!")
    Else
    $search = StringMid(GUICtrlRead($EditLOGFile), $a_sel[1] + 1, $a_sel[2] - $a_sel[1])
    MsgBox(0, "", "$search = " & $search)
    EndIf
    EndSelect
    WEnd


    Func Ende()
    Exit
    EndFunc ;==>Ende

    [/autoit]

    MfG. Oscar