MrKris1224 Posted November 2, 2014 Share Posted November 2, 2014 It's Possible? Create GUI Edit and if I write in edit word: "hello" then "hello" have for example red color and if i write "hello world" then hello have red color and world have yellow color? In Notepad ++ is a colored syntax. Is possible in autoit? Sorry for my bad english Link to comment Share on other sites More sharing options...
Rockerfeller Posted November 2, 2014 Share Posted November 2, 2014 Yes, but you need rich edit. Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 2, 2014 Author Share Posted November 2, 2014 Yes, but you need rich edit. Hmm... I know... Maybe can you give example...easy example...? I'am begginer Link to comment Share on other sites More sharing options...
Rockerfeller Posted November 2, 2014 Share Posted November 2, 2014 I dont understand, if you know why do you ask ? Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 2, 2014 Author Share Posted November 2, 2014 I dont understand, if you know why do you ask ? Sorry... I know that I need RichEdit but don'tknow how to use it Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 2, 2014 Author Share Posted November 2, 2014 Any help? Link to comment Share on other sites More sharing options...
BrewManNH Posted November 2, 2014 Share Posted November 2, 2014 Open the help file and run the examples for the RichEdit controls, learn how they work, modify them to your needs. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 3, 2014 Author Share Posted November 3, 2014 Open the help file and run the examples for the RichEdit controls, learn how they work, modify them to your needs. I don't understand help in atuoit.. My englis is bad.. I from poland... Can you create simple example to coler string in edit? Link to comment Share on other sites More sharing options...
MikahS Posted November 3, 2014 Share Posted November 3, 2014 _GUICtrlRichEdit_Create() Look at the example Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
guinness Posted November 3, 2014 Share Posted November 3, 2014 _GUICtrlRichEdit_Create() Look at the example Just so you're aware for the future, you can create an AutoIt code box and add the function name there. Then you don't have to waste your time searching for the link and doing all that mumbo jumbo! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
MikahS Posted November 3, 2014 Share Posted November 3, 2014 Just so you're aware for the future, you can create an AutoIt code box and add the function name there. Then you don't have to waste your time searching for the link and doing all that mumbo jumbo! I wasn't aware if they were aware they could use it like you have said, which is why I just gave the link. Still, thank you for taking the time to share the knowledge. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 4, 2014 Author Share Posted November 4, 2014 Still not got a concrete example of coloring different texts at once.... Link to comment Share on other sites More sharing options...
BrewManNH Posted November 4, 2014 Share Posted November 4, 2014 Still not got a concrete example of coloring different texts at once.... Are you really that lazy? expandcollapse popup#include <Color.au3> #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Global $g_idLblMsg, $g_hRichEdit Example() Func Example() Local $hGui, $iMsg, $idBtnNext, $iStep = 0 $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60) $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30) GUISetState(@SW_SHOW) _GUICtrlRichEdit_SetText($g_hRichEdit, "Paragraph 1") While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit Case $iMsg = $idBtnNext $iStep += 1 Switch $iStep Case 1 Report("1. Initial setting") Case 2 _GUICtrlRichEdit_SetCharColor($g_hRichEdit, "304050") Report("2. Setting is now") Case 3 _GUICtrlRichEdit_SetSel($g_hRichEdit, 1, 5) _GUICtrlRichEdit_SetCharColor($g_hRichEdit) Report("3. Background of a few characters changed") Case 4 _GUICtrlRichEdit_SetSel($g_hRichEdit, 6, -1) ; Stream all text to the Desktop so you can look at settings in Word _GUICtrlRichEdit_Deselect($g_hRichEdit) _GUICtrlRichEdit_StreamToFile($g_hRichEdit, @DesktopDir & "\gcre.rtf") Report("4. Saved to File") GUICtrlSetState($idBtnNext, $GUI_DISABLE) EndSwitch EndSelect WEnd EndFunc ;==>Example Func Report($sMsg) Local $iColor = _GUICtrlRichEdit_GetCharColor($g_hRichEdit) Local $sMixed = @extended ? "+" : "~" Local $aRet = _ColorGetRGB($iColor) $sMsg = $sMsg & @CRLF & @CRLF & $aRet[0] & ";" & $aRet[1] & ";" & $aRet[2] & " Color=0x" & Hex($iColor) & ":" & $sMixed GUICtrlSetData($g_idLblMsg, $sMsg) EndFunc ;==>Report From the help file I told you to open and look at and play with. You don't even need to be able to read the help file description if you can read the code. Next time do something for yourself. Being a leech gets you nothing around here. I only posted the above because it was a direct copy from the help file. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 4, 2014 Author Share Posted November 4, 2014 No example of the help file does not do what I want ... The program should automatically detect text and color it according to pre-defined rules. For example, every word "Hello" you write has to be yellow, then every word "World" has to be red. And so I want to set out the rules for coloring the text. And it has to happen on a regular basis when you will write something to a rich edit Link to comment Share on other sites More sharing options...
kaisies Posted November 4, 2014 Share Posted November 4, 2014 (edited) Examples will never do exactly what you want. Sounds like when you are passing the data into the rich you will have to split the text in an array of words, and add it in word by word with a switch based on the word value to change the color. Time to get coding. Start simple, with the example given, and you'll get there. Edited November 4, 2014 by kaisies Link to comment Share on other sites More sharing options...
johnmcloud Posted November 4, 2014 Share Posted November 4, 2014 (edited) expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Main() Func Main() Local $hGui, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "RichEdit - Test | Phoenix XL + Color by Johnmcloud ", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_CHANGE) Local $lblMsg = GUICtrlCreateLabel("'World' and 'Hello' ( not casesense ) are automatically colored upon typing.", 10, 235, 300, 60) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes GUIDelete() ; is OK too EndFunc ;==>Main Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iCode = BitShift($wParam, 16) ;HiWord If $iCode = $EN_CHANGE Then $s_Word = _GetCurrentWord($lParam) $i_WordPos = @extended Switch $s_Word Case "World" ; red ColorCurrentWord($lParam, $s_Word, $i_WordPos, _ColorConvert(0xFF0000)) Case "Hello" ; blue ColorCurrentWord($lParam, $s_Word, $i_WordPos, _ColorConvert(0x0000FF)) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func ColorCurrentWord($hRichEdit, $sWord, $iWordPos, $iColor, $iDefColor = 0x000000) Static $i_CheckBK ;a check for if backspace was pressed If _GUICtrlRichEdit_GetTextLength($hRichEdit) < $i_CheckBK Then $i_CheckBK = _GUICtrlRichEdit_GetTextLength($hRichEdit) ;backspace is pressed or chars deleted. Return EndIf _GUICtrlRichEdit_SetSel($hRichEdit, $iWordPos, $iWordPos + StringLen($sWord)) If _GUICtrlRichEdit_GetSelText($hRichEdit) <> $sWord Then ; BUG with line starting as first _GUICtrlRichEdit_Deselect($hRichEdit) Return EndIf _GUICtrlRichEdit_SetCharColor($hRichEdit, $iColor) _GUICtrlRichEdit_InsertText($hRichEdit, " ") _GUICtrlRichEdit_SetSel($hRichEdit, $iWordPos + StringLen($sWord), $iWordPos + StringLen($sWord) + 1) _GUICtrlRichEdit_SetCharColor($hRichEdit, $iDefColor) _GUICtrlRichEdit_Deselect($hRichEdit) $i_CheckBK = _GUICtrlRichEdit_GetTextLength($hRichEdit) EndFunc ;==>ColorCurrentWord Func _ColorConvert($nColor);RGB to BGR or BGR to RGB Return _ BitOR(BitShift(BitAND($nColor, 0x000000FF), -16), _ BitAND($nColor, 0x0000FF00), _ BitShift(BitAND($nColor, 0x00FF0000), 16)) EndFunc ;==>_ColorConvert ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetCaretOffset ; Description ...: Get the Offset of the Caret ; Syntax.........: _GetCaretOffset($Edit_ID) ; Parameters ....: $Edit_ID - The Control ID of the Edit Control ; ; Return values .: Success - Returns the Offset & Sets @extended to ; | 1 - A Selection is Present ; | 0 - No Selection is Present ; Failure - Returns -1 & Sets @error to 1 ; ; Author ........: Phoenix XL ; Modified.......: ; Remarks .......: Internally Used. from RichEditPredictText library ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/145398-predict-text-for-a-richedit-control-richeditpredicttextau3-udf/ ; Example .......: ; =============================================================================================================================== Func _GetCaretOffset($nRichEdit) Local $_LineIndex = _GUICtrlRichEdit_GetSel($nRichEdit) If Not IsArray($_LineIndex) Then Return SetError(1, @error, -1) Switch $_LineIndex[0] Case $_LineIndex[1] Return SetExtended(0, $_LineIndex[1]) Case Else $_LineIndex = _GUICtrlRichEdit_GetSelAA($nRichEdit) ;Its a Bug in the GUIRichEdit UDF [Switch the Anchor Point] _SendMessage($nRichEdit, $EM_SETSEL, $_LineIndex[0], $_LineIndex[1]) Return SetExtended(1, $_LineIndex[1]) EndSwitch EndFunc ;==>_GetCaretOffset ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetCurrentWord ; Description ...: Get the Current Word the Caret is Present at. ; Syntax.........: _GetCurrentWord($hRichEdit[, $cPos=-10[,$cEnter=0]]) ; Parameters ....: $hRichEdit - The Control ID of the Edit Control ; $cPos - For flexibility, used for getting the word at any other offset ; $cEnter - If Enter was Pressed then the Previous Line is Treated as the Primary Line ; | 1 - Check the Previous Line ; | 0 - Check the Present Line ; Return values .: Success - Returns the Word & Sets @extended to the character offset of the first alphabet of the word. ; Failure - Returns -1 & Sets @error to 1 ; ; Author ........: Phoenix XL ; Modified.......: ; Remarks .......: Internally Used. from RichEditPredictText library ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/145398-predict-text-for-a-richedit-control-richeditpredicttextau3-udf/ ; Example .......: ; =============================================================================================================================== Func _GetCurrentWord($hRichEdit, $cPos = -10, $cEnter = 0) If $cPos = -10 Then $cPos = _GetCaretOffset($hRichEdit) If $cPos < 0 Then Return SetError(1, $cPos, -1) Local $nLine = _GUICtrlRichEdit_GetLineNumberFromCharPos($hRichEdit, $cPos) $nLine -= $cEnter Local $nStart = _GUICtrlRichEdit_GetFirstCharPosOnLine($hRichEdit, -1) Local $nText = _GUICtrlRichEdit_GetTextInLine($hRichEdit, $nLine) Local $nWords = StringSplit($nText, ' ', 1) If @error Then Return SetError(2, 0, $nText) If $cEnter Then Return $nWords[$nWords[0]] For $n = 1 To $nWords[0] Switch $cPos Case $nStart To $nStart + StringLen($nWords[$n]) Return SetExtended($nStart, $nWords[$n]) EndSwitch $nStart += StringLen($nWords[$n]) + 1 Next Return SetError(1, 0, -1) EndFunc ;==>_GetCurrentWord BUG: When keyword is typed at start of line _GetCurrentWord don't return the correct position, i don't know how to solve it but for the rest work correct Edited November 4, 2014 by johnmcloud Link to comment Share on other sites More sharing options...
UEZ Posted November 4, 2014 Share Posted November 4, 2014 (edited) Here another example:expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("", 1024, 512) Global $hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 0, 0, 1024, 512, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) Global $iRichEdit = _WinAPI_GetDlgCtrlID($hRichEdit) _GUICtrlRichEdit_SetLimitOnText($hRichEdit, 0x20000) _GUICtrlRichEdit_SetBkColor($hRichEdit, 0x383838) Global $tCharFormat = DllStructCreate($tagCHARFORMAT) $tCharFormat.dwMask = $CFM_COLOR $tCharFormat.cbSize = DllStructGetSize($tCharFormat) Global $iCP = 0 Global $iCPMax = 0xFFFF WinSetTrans($hGUI, "", 0xD8) GUISetState() _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Introduction\line\line", 0x40, 0x40, 0xFF, 32, 1000) Global $aChars = StringSplit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.", "", 2), $i $iCP = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $iCPMax) For $i = 0 To UBound($aChars) - 1 _GUICtrlRichEdit_SetSel($hRichEdit, $iCP - 1, -1, True) $iColor = 0x60 + Int(($i + 1) / UBound($aChars) * (0xFF - 0x60)) _GUICtrlRichEdit_AppendTextEx($hRichEdit, $aChars[$i], 0xF0, 0x40, $iColor, 12, 10) Next _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "It uses a combination of simulated keystrokes, mouse movement ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "and window/control manipulation in order to automate tasks in a way not possible ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "self-contained and will run on all versions of Windows out-of-the-box with no annoying 'runtimes' required!\line\line", 0xFF, 0xFF, 0xFF, 12, 1500) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Progress: ", 0x38, 0xFF, 0x38, 12, 0) $iCP = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $iCPMax) For $i = 0x38 To 0xFF Step 2 _GUICtrlRichEdit_SetSel($hRichEdit, $iCP - 1, -1, True) _GUICtrlRichEdit_AppendTextEx($hRichEdit, Round($i / 0xFF * 100, 0) & " %", $i, $i, $i, 12 * $i / 0xFF, 10, 2) Next _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line\line", 0xFF, 0xFF, 0xFF, 8, 0) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Have fun with it :-)\line", 0xFF, 0x40, 0x40, 25, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line\line Press ESC!", 0xFF, 0xFF, 0x00, 8, 0) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Until False Func _GUICtrlRichEdit_AppendTextEx($hRichEdit, $sText, $iRed, $iGreen, $iBlue, $iFontSize, $iSleep = 100, $iMode = 1, $sFontname = "Consolas") ;coded by UEZ 2014 $iRed = $iRed < 0 ? 0 : $iRed > 0xFF ? 0xFF : $iRed $iGreen = $iGreen < 0 ? 0 : $iGreen > 0xFF ? 0xFF : $iGreen $iBlue = $iBlue < 0 ? 0 : $iBlue > 0xFF ? 0xFF : $iBlue Switch $iMode Case 1 _GUICtrlRichEdit_AppendText($hRichEdit, "{\rtf1\utf8{\fonttbl{\f0\fnil\fcharset0 " & $sFontname & ";}}{\colortbl;\red" & $iRed & "\green" & $iGreen & "\blue" & $iBlue & ";}\cf1 {\fs" & $iFontSize * 2 & " {" & $sText & "}}\cf0}") Case 2 _GUICtrlRichEdit_SetFont($hRichEdit, $iFontSize * 2, $sFontname) $tCharFormat.crCharColor = 0x10000 * $iBlue + 0x100 * $iGreen + $iRed _SendMessage($hRichEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") _GUICtrlRichEdit_ReplaceText($hRichEdit, $sText, False) EndSwitch Return Sleep($iSleep) EndFunc ;==>_GUICtrlRichEdit_AppendTextExBr,UEZ Edited November 4, 2014 by UEZ Inververs 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
MrKris1224 Posted November 4, 2014 Author Share Posted November 4, 2014 Here another example: expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("", 1024, 512) Global $hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 0, 0, 1024, 512, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) Global $iRichEdit = _WinAPI_GetDlgCtrlID($hRichEdit) _GUICtrlRichEdit_SetLimitOnText($hRichEdit, 0x20000) _GUICtrlRichEdit_SetBkColor($hRichEdit, 0x383838) Global $tCharFormat = DllStructCreate($tagCHARFORMAT) $tCharFormat.dwMask = $CFM_COLOR $tCharFormat.cbSize = DllStructGetSize($tCharFormat) Global $iCP = 0 Global $iCPMax = 0xFFFF WinSetTrans($hGUI, "", 0xD8) GUISetState() _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Introduction\line\line", 0x40, 0x40, 0xFF, 32, 1000) Global $aChars = StringSplit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting.", "", 2), $i $iCP = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $iCPMax) For $i = 0 To UBound($aChars) - 1 _GUICtrlRichEdit_SetSel($hRichEdit, $iCP - 1, -1, True) $iColor = 0x60 + Int(($i + 1) / UBound($aChars) * (0xFF - 0x60)) _GUICtrlRichEdit_AppendTextEx($hRichEdit, $aChars[$i], 0xF0, 0x40, $iColor, 12, 10) Next _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line", 0xFF, 0xFF, 0xFF, 12) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "It uses a combination of simulated keystrokes, mouse movement ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "and window/control manipulation in order to automate tasks in a way not possible ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, ", 0xFF, 0xFF, 0xFF, 12, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "self-contained and will run on all versions of Windows out-of-the-box with no annoying 'runtimes' required!\line\line", 0xFF, 0xFF, 0xFF, 12, 1500) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Progress: ", 0x38, 0xFF, 0x38, 12, 0) $iCP = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $iCPMax) For $i = 0x38 To 0xFF Step 2 _GUICtrlRichEdit_SetSel($hRichEdit, $iCP - 1, -1, True) _GUICtrlRichEdit_AppendTextEx($hRichEdit, Round($i / 0xFF * 100, 0) & " %", $i, $i, $i, 12 * $i / 0xFF, 10, 2) Next _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line\line", 0xFF, 0xFF, 0xFF, 8, 0) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "Have fun with it :-)\line", 0xFF, 0x40, 0x40, 25, 750) _GUICtrlRichEdit_AppendTextEx($hRichEdit, "\line\line Press ESC!", 0xFF, 0xFF, 0x00, 8, 0) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Until False Func _GUICtrlRichEdit_AppendTextEx($hRichEdit, $sText, $iRed, $iGreen, $iBlue, $iFontSize, $iSleep = 100, $iMode = 1, $sFontname = "Consolas") ;coded by UEZ 2014 $iRed = $iRed < 0 ? 0 : $iRed > 0xFF ? 0xFF : $iRed $iGreen = $iGreen < 0 ? 0 : $iGreen > 0xFF ? 0xFF : $iGreen $iBlue = $iBlue < 0 ? 0 : $iBlue > 0xFF ? 0xFF : $iBlue Switch $iMode Case 1 _GUICtrlRichEdit_AppendText($hRichEdit, "{\rtf1\utf8{\fonttbl{\f0\fnil\fcharset0 " & $sFontname & ";}}{\colortbl;\red" & $iRed & "\green" & $iGreen & "\blue" & $iBlue & ";}\cf1 {\fs" & $iFontSize * 2 & " {" & $sText & "}}\cf0}") Case 2 _GUICtrlRichEdit_SetFont($hRichEdit, $iFontSize * 2, $sFontname) $tCharFormat.crCharColor = 0x10000 * $iBlue + 0x100 * $iGreen + $iRed _SendMessage($hRichEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") _GUICtrlRichEdit_ReplaceText($hRichEdit, $sText, False) EndSwitch Return Sleep($iSleep) EndFunc ;==>_GUICtrlRichEdit_AppendTextEx Br, UEZ C:UsersKrzysiekDesktopAu3 & Projektypawo.au3(49,23) : ERROR: syntax error (illegal character) $iRed = $iRed < 0 ? ~~~~~~~~~~~~~~~~~~~~~~^ C:UsersKrzysiekDesktopAu3 & Projektypawo.au3(50,27) : ERROR: syntax error (illegal character) $iGreen = $iGreen < 0 ? ~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:UsersKrzysiekDesktopAu3 & Projektypawo.au3(51,25) : ERROR: syntax error (illegal character) $iBlue = $iBlue < 0 ? ~~~~~~~~~~~~~~~~~~~~~~~~^ C:UsersKrzysiekDesktopAu3 & Projektypawo.au3 - 3 error(s), 0 warning(s) Link to comment Share on other sites More sharing options...
Developers Jos Posted November 4, 2014 Developers Share Posted November 4, 2014 Guess there is an implicit question in that last post? Use the latest version of AutoIt3 for those lines to work. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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