BrettF Posted February 6, 2007 Share Posted February 6, 2007 (edited) This is my UDF (Thanks to anyone else who helped) that will cut or copy text from an edit control, to the clipboard. The code: A test: Hope this helps someone. Edit: 2 attachments the same?? Thanks heaps from SmOkeN for his help. His modded version: expandcollapse popupFunc _GUICtrlEditTextClipboard($nCID, $sType = '') Local $aSel = _GUICtrlEditGetSel($nCID) If $aSel = -1 Then Return SetError(1, 0, -1) Local $sText = StringMid(GUICtrlRead($nCID), $aSel[1] + 1, ($aSel[2] - $aSel[1]) + 1) If $sType = 'copy' Then Return ClipPut($sText) ClipPut($sText) Return _GUICtrlEditReplaceSel($nCID, 1, "") EndFunc ;==>_GUICtrlEditTextClipboard oÝ÷ ٩ݵë-jëh×6 #include <GUIConstants.au3> #include <GuiEdit.au3> 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 _GUICtrlEditTextClipboard($myedit) EndSelect WEnd Func _GUICtrlEditTextClipboard($nCID, $sType = '') Local $aSel = _GUICtrlEditGetSel($nCID) If $aSel = -1 Then Return SetError(1, 0, -1) Local $sText = StringMid(GUICtrlRead($nCID), $aSel[1] + 1, ($aSel[2] - $aSel[1]) + 1) If $sType = 'copy' Then Return ClipPut($sText) ClipPut($sText) Return _GUICtrlEditReplaceSel($nCID, True, "") EndFunc ;==>_GUICtrlEditTextClipboard Edited February 6, 2007 by 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! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 6, 2007 Moderators Share Posted February 6, 2007 Did you see that I modded your version here: http://www.autoitscript.com/forum/index.ph...st&p=302882 ? 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. Link to comment Share on other sites More sharing options...
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