Jump to content

Need help to string with RichEdit


Recommended Posts

Hello all there,

The first I would like to apologize for my very bad english. I'm am writing an application and I feel Autoit language made ​​me very interested and easy to apply. I having trouble sending string from my script to the WorldPad. I tried using the command ControlSetText to use, and it has successfully sent over the WorldPad text, but I do not understand why after sending it through WorldPad can not get the font color? I do not know how it can send the text color from tool send to WordPad. I hope everyone help me and i thank for this! Thank and good luck to all!

And this is the code currently my use

#Include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Global $hGui, $hRichEdit, $iMsg, $hControl


$hGui = GUICreate("Document Send", 320, 180)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 120, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_SetCharColor($hRichEdit, "304050")

_GUICtrlRichEdit_AppendText($hRichEdit, "This is more text")
$SendBNT = GUICtrlCreateButton("Send Text", 190, 135, 120, 30)

GUICtrlSetOnEvent($SendBNT, "GuiSendText")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()

While True
$iMsg = GUIGetMsg()
   Select
      Case $iMsg = $GUI_EVENT_CLOSE
      _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
      Exit
   EndSelect
WEnd

Func GuiSendText()
   $ToText = _GUICtrlRichEdit_GetText($hRichEdit)
   $wWHND = WinGetHandle("Document - WordPad", "")
   ControlSetText($wWHND, "", "[CLASS:RICHEDIT50W; INSTANCE:1]", $ToText)
EndFunc

Func _GUICtrlRichEdit_AppendTextEx($hWnd, $sText)
   Local $hParent = _WinAPI_GetParent($hWnd)
   ControlSetText($hParent, '', $hWnd, $sText )
EndFunc

Func _Exit()
   _GUICtrlRichEdit_Destroy($hRichEdit)
   GUIDelete()
   Exit
EndFunc

And Now Tool Send

NowToolSend.jpg

 

I want to here

WantToolSend.jpg

THANK FOR ALL HELPPPPP

Link to comment
Share on other sites

  • Moderators

XeThanh,

Please do not bump your own threads within 24 hours. :naughty:

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 4 weeks later...
  • Moderators

XeThanh,

Please do not SHOUT! Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. :mad:

You need to use the _GUICtrlRichEdit_Copy/Paste functions like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiRichEdit.au3>

Opt("GUIOnEventMode", 1)

$hGui = GUICreate("Document Send", 320, 180)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 120, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_SetCharColor($hRichEdit, 304050)
_GUICtrlRichEdit_AppendText($hRichEdit, "This is more text")

$SendBNT = GUICtrlCreateButton("Send Text", 190, 135, 120, 30)
GUICtrlSetOnEvent($SendBNT, "GuiSendText")

GUISetState()

While 1
   Sleep(10) ; No point in using GUIGetMsg in OnEvent mode <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
WEnd

Func GuiSendText()
    ; get curretn selection
    $aSel = _GUICtrlRichEdit_GetSel($hRichEdit)
    ; Select all text
    _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1)
    ; Caopy to clipboard
    _GUICtrlRichEdit_Copy($hRichEdit)
    ; Get WordPad edit handle - note on my Win7 system this is Instance 3 <<<<<<<<<<<<<<<<<<<<<<<
    $wWHND = ControlGetHandle("Document - WordPad", "", "[CLASS:RICHEDIT50W; INSTANCE:3]")
    ; Paste clipboard contents
    _GUICtrlRichEdit_Paste($wWHND)
    ; Reset original selection if stored
    If IsArray($aSel) Then
        _GUICtrlRichEdit_SetSel($hRichEdit, $aSel[0], $aSel[1])
    Else
        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0)
    EndIf
EndFunc

Func _Exit()
    _GUICtrlRichEdit_Destroy($hRichEdit)
    GUIDelete()
    Exit
EndFunc
Happy now? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

XeThanh,

Please do not SHOUT! Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. :mad:

You need to use the _GUICtrlRichEdit_Copy/Paste functions like this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiRichEdit.au3>

Opt("GUIOnEventMode", 1)

$hGui = GUICreate("Document Send", 320, 180)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 120, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_SetCharColor($hRichEdit, 304050)
_GUICtrlRichEdit_AppendText($hRichEdit, "This is more text")

$SendBNT = GUICtrlCreateButton("Send Text", 190, 135, 120, 30)
GUICtrlSetOnEvent($SendBNT, "GuiSendText")

GUISetState()

While 1
   Sleep(10) ; No point in using GUIGetMsg in OnEvent mode <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
WEnd

Func GuiSendText()
    ; get curretn selection
    $aSel = _GUICtrlRichEdit_GetSel($hRichEdit)
    ; Select all text
    _GUICtrlRichEdit_SetSel($hRichEdit, 0, -1)
    ; Caopy to clipboard
    _GUICtrlRichEdit_Copy($hRichEdit)
    ; Get WordPad edit handle - note on my Win7 system this is Instance 3 <<<<<<<<<<<<<<<<<<<<<<<
    $wWHND = ControlGetHandle("Document - WordPad", "", "[CLASS:RICHEDIT50W; INSTANCE:3]")
    ; Paste clipboard contents
    _GUICtrlRichEdit_Paste($wWHND)
    ; Reset original selection if stored
    If IsArray($aSel) Then
        _GUICtrlRichEdit_SetSel($hRichEdit, $aSel[0], $aSel[1])
    Else
        _GUICtrlRichEdit_SetSel($hRichEdit, 0, 0)
    EndIf
EndFunc

Func _Exit()
    _GUICtrlRichEdit_Destroy($hRichEdit)
    GUIDelete()
    Exit
EndFunc
Happy now? :)

M23

 

 

Thank MOD Melba23!!!!!!! It is amazing and I'm happy. It works well! Thank for you time support!!!!!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...