BrettF Posted February 3, 2007 Posted February 3, 2007 How can I Cut text from a selected portion of an edit box?? I have tried this: $cuter = _GUICtrlEditGetSel ($edit1) ClipPut (_GUICtrlEditSetSel ( $edit1, $cuter[1], $cuter[2]) ) _GUICtrlEditReplaceSel ($edit1,1,"") But it didnt word Thanks Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
BrettF Posted February 3, 2007 Author Posted February 3, 2007 Well that obviously wont work ... But how can i do it??? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
_Kurt Posted February 3, 2007 Posted February 3, 2007 Here's a small example that was slightly modified from the helpfile: expandcollapse popup;This will move over the users selected text by 1. #include <GUIConstants.au3> #include <GuiEdit.au3> 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() 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]) GUICtrlSetState($myedit, $GUI_FOCUS) ; keeps the focus on $myedit _GUICtrlEditSetSel($myedit, $a_sel[1]+1, $a_sel[2]+1) ; moves it over by 1 Else GUICtrlSetData($Status, "") EndIf EndSelect WEnd As you can see, _GUICtrlEditGetSel() returns NUMBERS of the starting and ending position of the selected text. What we did in this example is take those numbers, add 1 to each, and set the sel to the new starting and ending position. Kurt Awaiting Diablo III..
BrettF Posted February 4, 2007 Author Posted February 4, 2007 Didn't really help i'm afraid. How can i return the text selected in an editbox? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Shevilie Posted February 4, 2007 Posted February 4, 2007 GUICtrlSetData As above is posted Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
BrettF Posted February 4, 2007 Author Posted February 4, 2007 I think I'm confusing myself :"> Still dosn't help. All i want to happen is the selected text from the editbox to be copied to the clipboard. Kurt's example is great, except i cannot figure out how to use it. Forget the cut part. Just the copy. Thanks Bert. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Moderators SmOke_N Posted February 4, 2007 Moderators Posted February 4, 2007 (edited) I think I'm confusing myself :"> Still dosn't help. All i want to happen is the selected text from the editbox to be copied to the clipboard. Kurt's example is great, except i cannot figure out how to use it. Forget the cut part. Just the copy. Thanks Bert. Edit: Man, I need to keep up, never even noticed: _GUICtrlEditGetSel() Edit2: Local $WholeEdit = GUICtrlRead($myedit) Local $Trim = StringLeft(StringTrimLeft($WholeEdit, $a_sel[1]), $a_sel[2] - $a_sel[1]) ClipPut($Trim)Be sure to look at $Trim. Edited February 4, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
BrettF Posted February 4, 2007 Author Posted February 4, 2007 I seriously love you right now. SmokeN your my hero! lol Thanks heaps. I'll create a udf that does that now Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Moderators SmOke_N Posted February 4, 2007 Moderators Posted February 4, 2007 I seriously love you right now. SmokeN your my hero! lol Thanks heaps. I'll create a udf that does that now Func _GUICtrlEditReadSel($nCID) Local $aSel = _GUICtrlEditGetSel($nCID) If $aSel = -1 Then Return SetError(1, 0, -1) Return StringMid(GUICtrlRead($nCID), $aSel[1] + 1, ($aSel[2] - $aSel[1]) + 1) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now