Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_ColorConvertValue UDF


  • Please log in to reply
11 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 20 June 2009 - 10:19 AM

Hi there,

This function was initialy created as a helper function in my other recent UDF (_GUICtrlCreateTFLabel), but after searching on the forum for such function and not finding anything like this (i was surprised actualy, i thought this kind of function could be posted long time ago), i think that i should post it here.

The colors table i got from here.
In the archive with _ColorConvertValue there is also a parser script that i used to generate the table for UDF usage.

Function Header:
; #FUNCTION# ======================================================================================== ; Name...........:  _ColorConvertValue ; Description....:  Converts string color value to hex and back. ; Syntax.........:  _ColorConvertValue($sColor, $iConvertMode=-1, $aColors_Table=0) ; Parameters.....:  $sColor       - Color name or color hex value, depending on $iConvertMode. ;                    $iConvertMode  - [Optional] If this parameter <> -1, then the function will convert hex color to string value ;                                       (default is -1 - convert from string to hex). ;                    $aDefColorsTable - [Optional] If this parameter will contain an array with colors table (default is 0), ;                                       then this colors table will be used to convert the color. ;                   ; Return values..:  Success - Returns converted color value. ;                    Failure - Returns original $sColor value (if the color can not be converted). ; Author.........:  G.Sandler (MrCreatoR) ; Modified.......:  21.06.2009 ; Remarks........:  ; Related........:  ; Link...........:  Colors table used in this function: http://ilan.belhost.by/screens/colorx.shtml ; Example........:  Yes. ; ===================================================================================================


For example:

Blue converted to 0x0000FF
Red converted to 0xFF0000

and back...

0x0000FF to Blue
0xFF0000 to Red

Attachments:
v1.1 Attached File  _ColorConvertValue.zip   2.9KB   228 downloads
v1.0 Attached File  _ColorConvertValue.zip   2.69KB   157 downloads

Edited by MrCreatoR, 20 June 2009 - 11:34 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team








#2 AlmarM

AlmarM

    Programming my way.

  • Active Members
  • PipPipPipPipPipPip
  • 1,694 posts

Posted 20 June 2009 - 04:26 PM

Oh, thats pretty sweet. It doens't support ALL colors. Dont think thats necessary though.
This could be very useful! :D

Minesweeper

A minesweeper game created in autoit, source available.

 

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

 

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.


#3 James

James

    Universalist

  • MVPs
  • 10,293 posts

Posted 20 June 2009 - 04:50 PM

As I saw the topic, I was wondering how this would be done. Pretty nifty!

#4 GreenCan

GreenCan

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 319 posts

Posted 20 June 2009 - 05:46 PM

Nicely done, and useful too.

Thanks for sharing

GreenCan

#5 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 June 2009 - 05:46 PM

It's a good idea and well done, MrCreatoR, but it would be nice to be able to pass their own (arbitrary) color palette. Or make that something like _SetDefaultPalette(ByRef $aPalatte).

#6 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 20 June 2009 - 06:52 PM

Thanks to all for the feedbacks.

It's a good idea and well done, MrCreatoR, but it would be nice to be able to pass their own (arbitrary) color palette. Or make that something like _SetDefaultPalette(ByRef $aPalatte).


I am not sure that i follow you. What it should do exactly? (example could help).
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#7 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 June 2009 - 07:39 PM

I am not sure that i follow you. What it should do exactly? (example could help).

Dim $aDefColorsTable[140][2] = [[0xFFFFFF, 'White'],[0xFFFFF0, 'Ivory'], ...] Func _SetColorsTable(ByRef $aColorsTable)     ; Checks for $aColorsTable array         ...     $aDefColorsTable = $aColorsTable     Return 1 EndFunc   ;==>_SetColorsTable


In this case _ColorConvertValue() should work with a $aDefColorsTable array.

#8 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 20 June 2009 - 08:26 PM

; Checks for $aColorsTable array

What it should do inside the array? Switch the values?
Or you mean pass the array to use instead of the strings inside the UDF?

Edited by MrCreatoR, 20 June 2009 - 08:28 PM.

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#9 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 20 June 2009 - 10:13 PM

Your _ColorConvertValue() function works with local variables $aStrColors_Table and $aHexColors_Table. I think that would be more useful when the user can assign its value for these variables. For example, with an additional function _SetColorsTable(). In my example I used an array for simplicity. I think it is more convenient when the names of colors and their values are stored in the array. That's all.

#10 Ashalshaikh

Ashalshaikh

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 20 June 2009 - 10:21 PM

Nice ..
Thank You ...

#11 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 20 June 2009 - 11:30 PM

@Yashied
Ok, done.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#12 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,574 posts

Posted 21 June 2009 - 12:48 AM

Excellent.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users