Suppir Posted November 30, 2009 Share Posted November 30, 2009 Hello! I'm trying to send all data from _GUICtrlRichEdit_Create to the clipboard. See the code: #include <UDF\GuiRichEdit.au3> #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 800, 600, 300, 200) $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 0, 0, 800, 600) GUISetState(@SW_SHOW) HotKeySet("^x", "_SendTableToBuffer") HotKeySet("{ESC}", "_Exit") While 1 Sleep(100) WEnd Func _SendTableToBuffer() ;~ clears the clipboard ClipPut ( "" ) ;~ it does not work ClipPut(_GuiCtrlRichEdit_StreamToVar($hRichEdit)) EndFunc Func _Exit() Exit EndFunc 1. Run the script 2. Copy some ms-word' table to the GUI 3. Press CTRL+x # it clears clipboard and put all data from GUI to clipboard 4. Press CTRL+v # we have abrakadabra as the result How to send all data from GUICtrlRichEdit (inluding tables) to the clipboard? Thanks Link to comment Share on other sites More sharing options...
Mat Posted November 30, 2009 Share Posted November 30, 2009 have you tried: _GUICtrlRichEdit_GetText That could work, but I have not tried. AutoIt Project Listing Link to comment Share on other sites More sharing options...
ProgAndy Posted November 30, 2009 Share Posted November 30, 2009 (edited) To copy RTF to the clipboard you have to use special functions One way is to send WM_COPY to the RichEdit and let it do all the work (you have to select the things to copy first). Or you can set the Clipboard manually, but this needs work with Memory and Clipboard UDFs. Also the Beta is required for the second way. expandcollapse popup;#BETA #include <GuiRichEdit.au3> #include <GUIConstants.au3> $Form1 = GUICreate("Form1", 800, 600, 300, 200) $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 0, 0, 800, 600) GUISetState(@SW_SHOW) HotKeySet("^x", "_SendTableToBuffer") ; WM_COPY / _GUICtrlRichEdit_Copy HotKeySet("^y", "_SendTableToBuffer2") ; with Clipboard UDfs HotKeySet("{ESC}", "_Exit") While 1 Sleep(100) WEnd Func _SendTableToBuffer() ; alternative 1: _GUICtrlRichEdit_Copy($hRichEdit) EndFunc Func _Exit() _GUICtrlRichEdit_Destroy($hRichEdit) Exit EndFunc Func _SendTableToBuffer2() ; Author: Prog@ndy ;alternative 2: _ClipBoard_Open($hRichEdit) _ClipBoard_Empty() ; get Text $Data = _GUICtrlRichEdit_GetText($hRichEdit, True,1200) ; normal text $hMem = _MemGlobalAlloc(StringLen($Data), $GMEM_MOVEABLE) $struct = DllStructCreate("char[" & StringLen($Data) & "]", _MemGlobalLock($hMem)) DllStructSetData($struct, 1, $Data) _MemGlobalUnlock($hMem) _ClipBoard_SetDataEx($hMem, $CF_TEXT) ; unicode text $hMem = _MemGlobalAlloc(StringLen($Data)*2, $GMEM_MOVEABLE) $struct = DllStructCreate("wchar[" & StringLen($Data) & "]", _MemGlobalLock($hMem)) DllStructSetData($struct, 1, $Data) _MemGlobalUnlock($hMem) _ClipBoard_SetDataEx($hMem, $CF_UNICODETEXT) ; RTF with Objects: $Data = _GUICtrlRichEdit_StreamToVar($hRichEdit) $hMem = _MemGlobalAlloc(StringLen($Data), $GMEM_MOVEABLE) $struct = DllStructCreate("char[" & StringLen($Data) & "]", _MemGlobalLock($hMem)) DllStructSetData($struct, 1, $Data) _MemGlobalUnlock($hMem) _ClipBoard_SetDataEx($hMem, $_GRE_CF_RETEXTOBJ) ; RTF without objects: $Data = _GUICtrlRichEdit_StreamToVar($hRichEdit, True, False) $hMem = _MemGlobalAlloc(StringLen($Data), $GMEM_MOVEABLE) $struct = DllStructCreate("char[" & StringLen($Data) & "]", _MemGlobalLock($hMem)) DllStructSetData($struct, 1, $Data) _MemGlobalUnlock($hMem) _ClipBoard_SetDataEx($hMem, $_GRE_CF_RTF) _ClipBoard_Close() EndFunc Edited November 30, 2009 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Suppir Posted November 30, 2009 Author Share Posted November 30, 2009 Mat, it does not work. ProgAndy, thanks a lot! The problem was solved by the code: _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) _GuiCtrlRichEdit_Copy($hRichEdit) Link to comment Share on other sites More sharing options...
ProgAndy Posted November 30, 2009 Share Posted November 30, 2009 _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) _GuiCtrlRichEdit_Copy($hRichEdit) You could save the old selection, too: $aSel = _GUICtrlRichEdit_GetSel($hRichEdit) _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) _GUICtrlRichEdit_Copy($hRichEdit) If IsArray($aSel) Then _GUICtrlRichEdit_SetSel($hRichEdit, $aSel[0], $aSel[1]) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Suppir Posted November 30, 2009 Author Share Posted November 30, 2009 You could save the old selection, too:It can be usefull, thanks 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