Sign in to follow this  
Followers 0
BrettF

_GUICtrlEditTextClipboard

2 posts in this topic

#1 ·  Posted (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?? :whistle:

Thanks heaps from SmOkeN for his help. His modded version:

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, 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 by bert

Share this post


Link to post
Share on other sites



Did you see that I modded your version here: http://www.autoitscript.com/forum/index.ph...st&p=302882 ?


[center]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.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0