RickTK Posted June 11, 2019 Posted June 11, 2019 So I'm trying to save my coworker a lot of typing. He would like to presses F8 and the script entered the text. It worked nice with plain text, but now we need to have formatted text. I grabbed the text out of the RTF with Notepad++, but it just types directly verbatim. Is there a way to get the formatted text typed up? or maybe put the text into the clipboard and paste it in? Thanks in advance! Rick ^F8:: Send {Text} {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} {\colortbl ;\red255\green0\blue0;\red51\green102\blue255;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\f0\fs32 IN SHOP\cf0\i\fs30\par \i0\tab\ul\fs28 PRODUCTION\ulnone\fs24\par \tab\cf1 Piece 1\cf0 - \par \par \tab\ul\fs28 FINISHING\ulnone\fs24 \par \tab\cf1 Piece 1\cf0 - \par \par \fs30 ********************************************************\par \cf2\i\fs32 ON SITE\fs26\par \tab\cf3\bullet\par } return
Gianni Posted June 11, 2019 Posted June 11, 2019 I think you should use _GUICtrlRichEdit_StreamFromVar(); first, place in some way the formatted text in a var and then send the var content to the richedit via the _GUICtrlRichEdit_StreamFromVar() if you want use copy/paste you could copy the formatted text by hand to the clipboard, then transfer it to a var in your script using the ClipGet() function expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 650, 300, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 0, 0, 650, 300, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) ; you can get text from the clipboard ; Local $s = ClipGet() ; or ; set text directly in a variable Local $s = "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma;}}" & _ "{\colortbl ;\red255\green0\blue0;\red51\green102\blue255;\red0\green0\blue0;}" & _ "\viewkind4\uc1\pard\cf1\f0\fs32 IN SHOP\cf0\i\fs30\par" & _ "\i0\tab\ul\fs28 PRODUCTION\ulnone\fs24\par" & _ "\tab\cf1 Piece 1\cf0 - \par" & _ "\par" & _ "\tab\ul\fs28 FINISHING\ulnone\fs24 \par" & _ "\tab\cf1 Piece 1\cf0 - \par" & _ "\par" & _ "\fs30 ********************************************************\par" & _ "\cf2\i\fs32 ON SITE\fs26\par" & _ "\tab\cf3\bullet\par" & _ "}" _GUICtrlRichEdit_StreamFromVar($hRichEdit, $s) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit EndSelect WEnd EndFunc ;==>Example FrancescoDiMuro and RickTK 1 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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