Jump to content
InunoTaishou

Setting color of richedit

Recommended Posts

I know how to select, set color, then deselect but I'm trying to get more of a Microsoft word style richedit.

In word you can Highlight and change color, it only changes color of highlighted text, or you can change the color and it changes the color the text after the caret position.

Just doing _GUICtrlRichEdit_SetCharColor($hRichEdit, $color) changes the color for all of the text in the richedit and I'm trying to avoid that.

Is this possible?

Share this post


Link to post
Share on other sites

Which version of AutoIt you are using ?

in the current 3.3.14.2 you should first select text and then use  _GUICtrlRichEdit_SetCharColor($hRichEdit, $color)

 

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

I can use _GUICtrlRichEdit_SetSel($hRichEdit, $iAnchor, $iActive) to set that specific text but I'm trying to make it so that when I set the char color, all characters after the current point is the color and nothing in front of it is changed.

I'm trying to avoid checking the RichEdit control to see if the length has changed and selecting then changing the color

Share this post


Link to post
Share on other sites

Well I guess I just needed a couple of hours of tinkering away and it and going back to one of my old projects.

The solution is to use _SendMessage

Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))

And here's an example of how to use it.

#include <GuiRichEdit.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Color.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

AutoItSetOption("GuiOnEventMode", 1)

Global $frmMain = GUICreate("RichEdit Example", 580, 400)
Global $frmColorSelector = CreateColorSelector()
Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain)

GUISetState(@SW_SHOW, $frmMain)
GUISetState(@SW_SHOW, $frmColorSelector)

While (1)
    Sleep(100)
Wend

Func Close()
    GUIDelete($frmColorSelector)
    GUIDelete($frmMain)
    
    Exit(0)
EndFunc

Func CreateColorSelector()
Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain)
GUICtrlCreateLabel("",2,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000000")
GUICtrlCreateLabel("",2,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800000")
GUICtrlCreateLabel("",2,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF0000")
GUICtrlCreateLabel("",2,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF00FF")
GUICtrlCreateLabel("",2,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF99CC")
GUICtrlCreateLabel("",16,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993300")
GUICtrlCreateLabel("",16,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF6600")
GUICtrlCreateLabel("",16,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF9900")
GUICtrlCreateLabel("",16,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC00")
GUICtrlCreateLabel("",16,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC99")
GUICtrlCreateLabel("",30,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333300")
GUICtrlCreateLabel("",30,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808000")
GUICtrlCreateLabel("",30,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CC00")
GUICtrlCreateLabel("",30,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF00")
GUICtrlCreateLabel("",30,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF99")
GUICtrlCreateLabel("",44,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003300")
GUICtrlCreateLabel("",44,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008000")
GUICtrlCreateLabel("",44,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x339966")
GUICtrlCreateLabel("",44,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FF00")
GUICtrlCreateLabel("",44,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFCC")
GUICtrlCreateLabel("",58,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003366")
GUICtrlCreateLabel("",58,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008080")
GUICtrlCreateLabel("",58,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x33CCCC")
GUICtrlCreateLabel("",58,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FFFF")
GUICtrlCreateLabel("",58,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFFF")
GUICtrlCreateLabel("",72,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000080")
GUICtrlCreateLabel("",72,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x0000FF")
GUICtrlCreateLabel("",72,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x3366FF")
GUICtrlCreateLabel("",72,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00CCFF")
GUICtrlCreateLabel("",72,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CCFF")
GUICtrlCreateLabel("",86,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333399")
GUICtrlCreateLabel("",86,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x666699")
GUICtrlCreateLabel("",86,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800080")
GUICtrlCreateLabel("",86,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993366")
GUICtrlCreateLabel("",86,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCC99FF")
GUICtrlCreateLabel("",100,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333333")
GUICtrlCreateLabel("",100,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808080")
GUICtrlCreateLabel("",100,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x999999")
GUICtrlCreateLabel("",100,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xC0C0C0")
GUICtrlCreateLabel("",100,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG))
Return $hWnd_gui
EndFunc

Func SetColor()
    Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId)
    
    If ($selected_color > -1) Then
        Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))
    EndIf
    
    _WinAPI_SetFocus($rtfEdit)
EndFunc   ;==>SetColor

Func GUICtrlGetBkColor($iControlID)
    Local $hHandle = GUICtrlGetHandle($iControlID)
    Local $hDC = _WinAPI_GetDC($hHandle)
    Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2)
    
    Return $bGetBkColor
EndFunc ;==>GUICtrlGetBkColor

 

Share this post


Link to post
Share on other sites

Which version of AutoIt you are using ?

You did not answer.
This is important, as in the last relaese there were changes.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

I told you 2 hours ago :)

 

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Since we're talking about rich edit...

Whenever I do _GUICtrlRichEdit_StreamToFile or _GUICtrlRichEdit_StreamFromFile (Idk which is doing it) it will append an extra line to the RichEdit. Any particular reason why? I'm not using any extra parameters other than the handle and the file

Share this post


Link to post
Share on other sites

Make a repro snippet, to show what you mean.

btw.
Cool idea with this draging color palette.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

Share this post


Link to post
Share on other sites

Same example as the one above except I added

_GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf")

Right after creating the RichEdit and

_GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf")

Right before deleting the GUI

Opening and closing it constantly adds an extra new line to the end. I don't know if it's coming from StreamFromFile or StreamToFile

#include <GuiRichEdit.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Color.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>

AutoItSetOption("GuiOnEventMode", 1)

Global $frmMain = GUICreate("RichEdit Example", 580, 400)
Global $frmColorSelector = CreateColorSelector()
Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf")

GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain)

GUISetState(@SW_SHOW, $frmMain)
GUISetState(@SW_SHOW, $frmColorSelector)

While (1)
    Sleep(100)
Wend

Func Close()
    _GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf")
    GUIDelete($frmColorSelector)
    GUIDelete($frmMain)
    
    Exit(0)
EndFunc

Func CreateColorSelector()
Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain)
GUICtrlCreateLabel("",2,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000000")
GUICtrlCreateLabel("",2,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800000")
GUICtrlCreateLabel("",2,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF0000")
GUICtrlCreateLabel("",2,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF00FF")
GUICtrlCreateLabel("",2,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF99CC")
GUICtrlCreateLabel("",16,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993300")
GUICtrlCreateLabel("",16,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF6600")
GUICtrlCreateLabel("",16,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFF9900")
GUICtrlCreateLabel("",16,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC00")
GUICtrlCreateLabel("",16,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFCC99")
GUICtrlCreateLabel("",30,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333300")
GUICtrlCreateLabel("",30,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808000")
GUICtrlCreateLabel("",30,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CC00")
GUICtrlCreateLabel("",30,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF00")
GUICtrlCreateLabel("",30,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xFFFF99")
GUICtrlCreateLabel("",44,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003300")
GUICtrlCreateLabel("",44,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008000")
GUICtrlCreateLabel("",44,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x339966")
GUICtrlCreateLabel("",44,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FF00")
GUICtrlCreateLabel("",44,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFCC")
GUICtrlCreateLabel("",58,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x003366")
GUICtrlCreateLabel("",58,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x008080")
GUICtrlCreateLabel("",58,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x33CCCC")
GUICtrlCreateLabel("",58,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00FFFF")
GUICtrlCreateLabel("",58,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCCFFFF")
GUICtrlCreateLabel("",72,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x000080")
GUICtrlCreateLabel("",72,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x0000FF")
GUICtrlCreateLabel("",72,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x3366FF")
GUICtrlCreateLabel("",72,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x00CCFF")
GUICtrlCreateLabel("",72,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x99CCFF")
GUICtrlCreateLabel("",86,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333399")
GUICtrlCreateLabel("",86,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x666699")
GUICtrlCreateLabel("",86,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x800080")
GUICtrlCreateLabel("",86,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x993366")
GUICtrlCreateLabel("",86,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xCC99FF")
GUICtrlCreateLabel("",100,2,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x333333")
GUICtrlCreateLabel("",100,16,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x808080")
GUICtrlCreateLabel("",100,30,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0x999999")
GUICtrlCreateLabel("",100,44,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlSetBkColor(-1,"0xC0C0C0")
GUICtrlCreateLabel("",100,58,14,14,-1,512)
GUICtrlSetOnEvent(-1,"SetColor")
GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG))
Return $hWnd_gui
EndFunc

Func SetColor()
    Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId)
    
    If ($selected_color > -1) Then
        Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
        
        DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
        DllStructSetData($tCharFormat, 2, $CFM_COLOR)
        DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6))))
        _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))
    EndIf
    
    _WinAPI_SetFocus($rtfEdit)
EndFunc   ;==>SetColor

Func GUICtrlGetBkColor($iControlID)
    Local $hHandle = GUICtrlGetHandle($iControlID)
    Local $hDC = _WinAPI_GetDC($hHandle)
    Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2)
    
    Return $bGetBkColor
EndFunc ;==>GUICtrlGetBkColor

 

Share this post


Link to post
Share on other sites

This was asked before:

Some other discussion over the internet:

http://codeverge.com/embarcadero.delphi.vcl.using/problem-with-trichedit-in-xe5-em/1079375

http://www.devsuperpage.com/search/Articles.aspx?G=2&ArtID=106552

I have no Idea why, first I can think this is internal MS Component behavior, but I'm not sure.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2019-10-01

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

  • Similar Content

    • By argumentum
      ..I'm coding the High Contrast theme editor and using the _ChooseColor() I wandered why it does not keep the the custom colors I've added.
      Found that adding a static declaration would do it. But why stop there. Why not keep going, So I put this together that is non code braking ( backwards compatible ), to replace the one in <Misc.au3>
      _ChooseColor_mod_Example() Func _ChooseColor_mod_Example() Local $aCustColors[17] $aCustColors[1] = 0xFF0000 $aCustColors[16] = 0x0000FF $aCustColors = _ChooseColor_mod(2, "0x00ff00", 2, 0, $aCustColors) ConsoleWrite(@CRLF & $aCustColors[0] & @CRLF & @CRLF) ConsoleWrite(@CRLF & _ChooseColor_mod(2, $aCustColors[0], 2, 0, $aCustColors)[0] & @CRLF & @CRLF) ConsoleWrite(@CRLF & _ChooseColor_mod(2, "0x00ff00", 2) & @CRLF & @CRLF) ; just as default behaviour ConsoleWrite(@CRLF & _ChooseColor_mod(2, "0x00ff00", 2, 0, 'reset as is neither "Default" nor "Array[17]"') & @CRLF & @CRLF) ; just as default behaviour EndFunc ;==>_ChooseColor_mod_Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ChooseColor_mod ; Description ...: ; Syntax ........: _ChooseColor_mod([$iReturnType = 0[, $iColorRef = 0[, $iRefType = 0[, $hWndOwnder = 0[, $vCustColors = Default]]]]]) ; Parameters ....: $iReturnType - [optional] an integer value. Default is 0. See remarks for values. ; $iColorRef - [optional] an integer value. Default is 0. ; $iRefType - [optional] an integer value. Default is 0. See remarks for values. ; $hWndOwnder - [optional] a handle to the parent window. Default is 0. ; $vCustColors - [optional] an array of colors to show as custom values. See remarks for values. ; Return values .: Success - Hex value of the selected color ; Failure - $vCustomColors is returned if set, otherwise, -1 is returned. Also sets @error: ; | -2 - User initialized $tagCustcolors via $vCustColors. ; | -3 - User canceled or invalid dll struct. ; | -4 - Invalid $iReturnType value. ; | Other - Error returned from Dll call. ; Author ........: Gary Frost (gafrost) ; Modified ......: argumentum ; Remarks .......: $iReturnType can be 0 (RGB COLORREF), 1 (Hex BGR), or 2 (Hex RGB). ; $iRefType can be 0 (ColorRef), 1 (BGR Hex), or 2 (RGB Hex). ; $vCustColors is a zero based array[17] where: ; index 0 hold the color returned by the function. ; index 1 to 16 are the colors to use in Custom colors in RGB. ; One can pass the array with array[0] = -2 to initialize the custom colors without loading the interface. ; When $vCustColors is used, it returns the modified array. ( not the color as integer ). ; Anything other than Default or a proper array, will clear $tagCustcolors ( holder of the custom colors ). ; When $vCustColors is omited or Default, $tagCustcolors is kept ( hence, no need for the array to keep custom colors ). ; Related .......: Same Func from <Misc.au3> ; Link ..........: https://www.autoitscript.com/forum/topic/200985-_choosecolor-but-better/ ; Example .......: YES ; =============================================================================================================================== Func _ChooseColor_mod($iReturnType = 0, $iColorRef = 0, $iRefType = 0, $hWndOwnder = 0, $vCustColors = Default) ; basic code from Misc.au3 ; https://www.autoitscript.com/forum/topic/200985-_choosecolor-but-better/ ; added here for independance of #include <Misc.au3> Local Static $tagCHOOSECOLOR = "dword Size;hwnd hWndOwnder;handle hInstance;dword rgbResult;ptr CustColors;dword Flags;lparam lCustData;" & _ "ptr lpfnHook;ptr lpTemplateName" Local Static $__MISCCONSTANT_CC_ANYCOLOR = 0x0100 Local Static $__MISCCONSTANT_CC_FULLOPEN = 0x0002 Local Static $__MISCCONSTANT_CC_RGBINIT = 0x0001 ; added here for independance of #include <Misc.au3> Local $vReturn, $bCustColors = False, $tagCustcolors = "dword[16]" Local $tChoose = DllStructCreate($tagCHOOSECOLOR) Local Static $tCc = DllStructCreate($tagCustcolors) ; added Static (mod.), to keep $tagCustcolors changes by user when called again. If $vCustColors == Default Then ; nothing ElseIf UBound($vCustColors) = 17 Then $bCustColors = True For $n = 1 To 16 DllStructSetData($tCc, 1, $vCustColors[$n], $n) Next Else $tCc = DllStructCreate($tagCustcolors) ; reset, just in case you'd want to have it default again EndIf If $iRefType = 1 Then ; BGR hex color to colorref $iColorRef = Int($iColorRef) ElseIf $iRefType = 2 Then ; RGB hex color to colorref $iColorRef = Hex(String($iColorRef), 6) $iColorRef = '0x' & StringMid($iColorRef, 5, 2) & StringMid($iColorRef, 3, 2) & StringMid($iColorRef, 1, 2) EndIf DllStructSetData($tChoose, "Size", DllStructGetSize($tChoose)) DllStructSetData($tChoose, "hWndOwnder", $hWndOwnder) DllStructSetData($tChoose, "rgbResult", $iColorRef) DllStructSetData($tChoose, "CustColors", DllStructGetPtr($tCc)) DllStructSetData($tChoose, "Flags", BitOR($__MISCCONSTANT_CC_ANYCOLOR, $__MISCCONSTANT_CC_FULLOPEN, $__MISCCONSTANT_CC_RGBINIT)) Local $aResult = DllCall("comdlg32.dll", "bool", "ChooseColor", "struct*", $tChoose) If @error Then If Not $bCustColors Then Return SetError(@error, @extended, -1) Else $vCustColors[0] = -1 Return SetError(@error, @extended, $vCustColors) EndIf EndIf If $bCustColors Then ; this here is better than at the end, For $n = 1 To 16 ; that way you'll get the custom colors anyway. $vCustColors[$n] = DllStructGetData($tCc, 1, $n) Next If $vCustColors[0] = -2 Then Return $vCustColors EndIf If $aResult[0] = 0 Then ; Return SetError(-3, -3, -1) ; user selected cancel or struct settings incorrect If Not $bCustColors Then Return SetError(-3, -3, -1) Else $vCustColors[0] = -1 Return SetError(-3, -3, $vCustColors) EndIf EndIf Local $sColor_picked = DllStructGetData($tChoose, "rgbResult") If $iReturnType = 1 Then ; return Hex BGR Color $vReturn = '0x' & Hex(String($sColor_picked), 6) ElseIf $iReturnType = 2 Then ; return Hex RGB Color $sColor_picked = Hex(String($sColor_picked), 6) $vReturn = '0x' & StringMid($sColor_picked, 5, 2) & StringMid($sColor_picked, 3, 2) & StringMid($sColor_picked, 1, 2) ElseIf $iReturnType = 0 Then ; return RGB COLORREF $vReturn = $sColor_picked Else $vReturn = -1 SetError(-4, -4) EndIf If Not $bCustColors Then Return $vReturn $vCustColors[0] = $vReturn Return $vCustColors EndFunc ;==>_ChooseColor_mod Hopefully will replace the default one in the next release 
    • By DannyJ
      Hello Forum, 
      I have one special Combo-box [with BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE) ] and if I press one button I want to change the Combo-box's background color, and after I press Button B I want to change it to the basic settings and it not works.
      I wanna do this with one combo-box.
      I have already tried several methods and I tried  GUICtrlComboSetColors that I have found on this forum.
      (But this methods works perfectly with Cobo boxes that don't have BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE). 
      Here is the example code
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= ;$CBS_DROPDOWNLIST ;$GUI_SS_DEFAULT_COMBO $Form1 = GUICreate("Form1", 504, 249, 252, 227) $Combo1 = GUICtrlCreateCombo("", 136, 24, 193, 25,BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; I want to change this special combo's background color if I press button 1 $Button1 = GUICtrlCreateButton("Button1", 112, 96, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 264, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Combo1," " & "|" & "apple" & "|" & "banana" & "|" & "cherry" ," ") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetBkColor($Combo1,0x0078D7) Case $Button2 ;Makes the original bc color GUICtrlSetBkColor($Combo1,0xFFFFFF) EndSwitch WEnd  
      Thanks you in advance your help
    • By user4157124
      ConsoleWrite('>Message here.' & @CRLF) outputs colored text (per + > - ! characters).
      ConsoleWrite('warning' & @TAB & '38' & @TAB & 'more text ...' & @CRLF) enables jump to line 38 on doubleclick.

      Using "jump to line" format, only red and pink text coloring seems possible (simply prefixing color directives to output-text disables jump to line functionality). Is it possible to combine the two (define custom color while keeping "jump to line" functionality)?
    • By Miliardsto
      I have the following code. You can see there are $color_normal and $color_trans
      In my case normal is too dark . And color trans is to much violet.
      If you run it you will see how its looks. I want gui with listView have the same color like taskbar in windows 10.
      How to achieve that?
       
       
      #include <Date.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> HotKeySet("{ESC}", "Terminate") $color_normal = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) $color_trans = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) $trans = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") ConsoleWrite("Transpart = " & $trans & @CRLF) ConsoleWrite("Color normal = " & $color_normal & @CRLF) ConsoleWrite("Color trans = " & $color_trans & @CRLF) ConsoleWrite(_Get_taskbar_color()); It return AARRGGBB $taskbarColor = _Get_taskbar_color() Global $gui = GUICreate("Test", 150, 58,@DesktopWidth-300,@DesktopHeight-58,$WS_POPUP,BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Global $idListview = GUICtrlCreateListView("", 0, 0, 150, 58,BitOR($LBS_NOTIFY,$LBS_SORT), 0) ;_GuiCtrlMakeTrans(-1,100) ; Add column _GUICtrlListView_AddColumn($idListview, "Msgs", 100) GUICtrlSetFont(-1, 7, 400, 0, "Segoe UI") GUICtrlSetColor(-1, 0x470C4F) GUICtrlSetBkColor($idListview, 0x310638) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Terminate() Exit EndFunc Func _Get_taskbar_color() If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence") Then If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) Else Return "0xFF" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) EndIf Else If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9000000" Else Return "0xFF000000" EndIf EndIf EndFunc  
    • By dejhost
      Happy New Year everyone!
      I would like to extract the color values of certain pixels in an image.  This is how I picture the workflow: 
      User opens an image of his choice. Image is shown on the screen. User draws a line into the image. This happens by marking the startpixel and the endpixel of the line The line is drawn, so the user can check visually if he is happy with the line.  The following pixel based properties belonging to the line are stored in Excel: X-Coordinate Y-Coordinate Color Value Additional operations: Extracting for max- and min. color values; Statistical operations.   Browsing through the helpfile of AutoIt I find plenty of functions for treating images (e.g. GDIPlus), but I am completely unsure if Autoit will get me there. Should I read the entire image into an array? Should I rather attempt to script an external image software (e.g. IrfanView, Gimp)?
      I would be very thankful if someone could give some recommendations and maybe list a couple of the most important commands to use.
      Thank you very much.
      Dejhost
       
       
×
×
  • Create New...