Tyleo-Dev-AutoIT-Oldies/Color Picker/ColorPicker For AutoIT Coder.au3

386 lines
13 KiB
AutoIt
Raw Normal View History

2024-02-18 21:17:39 +00:00
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Aslinks Ico.ico
#AutoIt3Wrapper_Outfile=..\..\Logiciels\HEXColorPicker_Unified_x32-x86.exe
#AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\HEXColorPicker_Unified_x64.exe
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_Res_Comment=HEX Color Picker Unified
#AutoIt3Wrapper_Res_Description=HEX Color Picker Unified
#AutoIt3Wrapper_Res_Fileversion=2.0.4.3
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=HEX Color Picker Unified
#AutoIt3Wrapper_Res_ProductVersion=2.0.4.0
#AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares
#AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares
#AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include "TyleoAboutMe.au3"
; Fixed Color Vars
$FullWhite = "FFFFFF"
$FullBlack = "000000"
$MatrixGreen = "0DFF06"
$MatrixDarkBlue = "040033"
$DiscordDark = "2C2F33"
$Ice = "4ACBE1"
$GoogleGreen = "34A853"
$GoogleDark = "202124"
$GoogleBlue = "4285F4"
$GoogleRed = "EA4335"
$GoogleYellow = "FBBC05"
$Sand = "E3CCBA"
$Buttercup = "e49326"
$MicrosoftYellow = "FEF000"
$BrightPink = "FF06FF"
$Espresso = "784018"
$DiscordGray = "99AAB5"
$DiscordBluev1 = "5865F2"
$DiscordBluev2 = "404EED"
$FacebookClassic = "4267B2"
$FacebookBlue = "1877F2"
$Mint = "ACCCAC"
$MaterialBlue = "0080FF"
$Win11Blue = "0067B8"
$Magenta = "C219BF"
$AltColor1 = "CC0000"
$AltColor2 = "9400EC"
$CodeName = "ASLINKS"
$CurrentVer = FileGetVersion(@AutoItExe) & " " & $CodeName
$Prog = "Color Picker for AutoIT " & $CurrentVer
#Region ### START Koda GUI section ### Form=
Global $GUI = GUICreate($Prog, 460, 125, 295, 325)
Global $PickColor = GUICtrlCreateButton("Pick Color", 8, 55, 209, 41)
GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
GUICtrlSetColor(-1,0x000000)
GUICtrlSetBkColor(-1,0xFFFFFF)
Global $HEX = GUICtrlCreateInput("", 8, 8, 209, 41, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$WS_EX_WINDOWEDGE))
GUICtrlSetFont(-1, 20, 400, 0, "Segoe UI")
GUICtrlSetColor(-1,0x000000)
GUICtrlSetBkColor(-1,0xFFFFFF)
Global $GUI_Menu_File = GUICtrlCreateMenu("File")
Global $GUI_Menu_File_Save = GUICtrlCreateMenuItem("Save Color to Base",$GUI_Menu_File)
Global $GUI_Menu_File_OpenBase = GUICtrlCreateMenuItem("Open Color Base",$GUI_Menu_File)
Global $GUI_Menu_File_Refresh = GUICtrlCreateMenuItem("Refresh Color List",$GUI_Menu_File)
GUICtrlCreateMenuItem("",$GUI_Menu_File)
Global $GUI_Menu_File_Remove = GUICtrlCreateMenuItem("Delete this color",$GUI_Menu_File)
Global $GUI_Menu_Color = GUICtrlCreateMenu("Color")
Global $GUI_Menu_Color_ExportNoAutoIT = GUICtrlCreateMenuItem("Copy Non AutoIT Color Code (Without '0x')",$GUI_Menu_Color)
Global $GUI_Menu_Options = GUICtrlCreateMenu("Options")
Global $GUI_Menu_Options_EditCfg = GUICtrlCreateMenuItem("Edit Color Base Location",$GUI_Menu_Options)
Global $GUI_Menu_About = GUICtrlCreateMenu("About")
Global $GUI_Menu_About_Dev = GUICtrlCreateMenuItem("Developers",$GUI_Menu_About)
Global $GUI_Menu_About_Ver = GUICtrlCreateMenuItem("Color Picker " & $CurrentVer,$GUI_Menu_About)
GUICtrlSetState($GUI_Menu_About_Ver,$GUI_DISABLE)
; Color Fixed Set
Global $CFS_1 = GUICtrlCreateButton("", 380, 7, 15, 15)
DefineBkFromHex(-1, $GoogleDark)
GUICtrlSetTip(-1, "Google Dark")
GUICtrlSetCursor(-1, 0)
Global $CFS_2 = GUICtrlCreateButton("", 395, 7, 15, 15)
DefineBkFromHex(-1, $GoogleGreen)
GUICtrlSetTip(-1, "Google Green")
GUICtrlSetCursor(-1, 0)
Global $CFS_3 = GUICtrlCreateButton("", 410, 7, 15, 15)
DefineBkFromHex(-1, $GoogleRed)
GUICtrlSetTip(-1, "Google Red")
GUICtrlSetCursor(-1, 0)
Global $CFS_4 = GUICtrlCreateButton("", 425, 7, 15, 15)
DefineBkFromHex(-1, $GoogleYellow)
GUICtrlSetTip(-1, "Google Yellow")
GUICtrlSetCursor(-1, 0)
Global $CFS_5 = GUICtrlCreateButton("", 440, 7, 15, 15)
DefineBkFromHex(-1, $FacebookBlue)
GUICtrlSetTip(-1, "Facebook Blue")
GUICtrlSetCursor(-1, 0)
Global $CFS_6 = GUICtrlCreateButton("", 380, 25, 15, 15)
DefineBkFromHex(-1, $FacebookClassic)
GUICtrlSetTip(-1, "Facebook Classic Blue")
GUICtrlSetCursor(-1, 0)
Global $CFS_7 = GUICtrlCreateButton("", 395, 25, 15, 15)
DefineBkFromHex(-1, $DiscordBluev1)
GUICtrlSetTip(-1, "Discord Blue v1")
GUICtrlSetCursor(-1, 0)
Global $CFS_8 = GUICtrlCreateButton("", 410, 25, 15, 15)
DefineBkFromHex(-1, $DiscordBluev2)
GUICtrlSetTip(-1, "Discord Blue v2")
GUICtrlSetCursor(-1, 0)
Global $CFS_9 = GUICtrlCreateButton("", 425, 25, 15, 15)
DefineBkFromHex(-1, $DiscordDark)
GUICtrlSetTip(-1, "Discord Dark")
GUICtrlSetCursor(-1, 0)
Global $CFS_10 = GUICtrlCreateButton("", 440, 25, 15, 15)
DefineBkFromHex(-1, $DiscordGray)
GUICtrlSetTip(-1, "Discord Gray")
GUICtrlSetCursor(-1, 0)
Global $CFS_11 = GUICtrlCreateButton("", 380, 25 + 18, 15, 15)
DefineBkFromHex(-1, $Buttercup)
GUICtrlSetTip(-1, "Buttercup")
GUICtrlSetCursor(-1, 0)
Global $CFS_12 = GUICtrlCreateButton("", 395, 25 + 18, 15, 15)
DefineBkFromHex(-1, $Ice)
GUICtrlSetTip(-1, "Ice")
GUICtrlSetCursor(-1, 0)
Global $CFS_13 = GUICtrlCreateButton("", 410, 25 + 18, 15, 15)
DefineBkFromHex(-1, $MaterialBlue)
GUICtrlSetTip(-1, "Material Blue")
GUICtrlSetCursor(-1, 0)
Global $CFS_14 = GUICtrlCreateButton("", 425, 25 + 18, 15, 15)
DefineBkFromHex(-1, $Win11Blue)
GUICtrlSetTip(-1, "Windows 11 Blue")
GUICtrlSetCursor(-1, 0)
Global $CFS_15 = GUICtrlCreateButton("", 440, 25 + 18, 15, 15)
DefineBkFromHex(-1, $MatrixGreen)
GUICtrlSetTip(-1, "MATRIX Green")
GUICtrlSetCursor(-1, 0)
Global $CFS_16 = GUICtrlCreateButton("", 380, 25 + 36, 15, 15)
DefineBkFromHex(-1, $MatrixDarkBlue)
GUICtrlSetTip(-1, "MATRIX Dark Blue")
GUICtrlSetCursor(-1, 0)
Global $CFS_17 = GUICtrlCreateButton("", 395, 25 + 36, 15, 15)
DefineBkFromHex(-1, $Espresso)
GUICtrlSetTip(-1, "Espresso What Else")
GUICtrlSetCursor(-1, 0)
Global $CFS_18 = GUICtrlCreateButton("", 410, 25 + 36, 15, 15)
DefineBkFromHex(-1, $Sand)
GUICtrlSetTip(-1, "Sand")
GUICtrlSetCursor(-1, 0)
Global $CFS_19 = GUICtrlCreateButton("", 425, 25 + 36, 15, 15)
DefineBkFromHex(-1, $Mint)
GUICtrlSetTip(-1, "Mint")
GUICtrlSetCursor(-1, 0)
Global $CFS_20 = GUICtrlCreateButton("", 440, 25 + 36, 15, 15)
DefineBkFromHex(-1, $Magenta)
GUICtrlSetTip(-1, "Magenta")
GUICtrlSetCursor(-1, 0)
Global $CFS_21 = GUICtrlCreateButton("", 380, 25 + 54, 15, 15)
DefineBkFromHex(-1, $BrightPink)
GUICtrlSetTip(-1, "Bright Pink")
GUICtrlSetCursor(-1, 0)
Global $CFS_22 = GUICtrlCreateButton("", 395, 25 + 54, 15, 15)
DefineBkFromHex(-1, $AltColor1)
GUICtrlSetTip(-1, "Dev Choice #1")
GUICtrlSetCursor(-1, 0)
Global $CFS_23 = GUICtrlCreateButton("", 410, 25 + 54, 15, 15)
DefineBkFromHex(-1, $AltColor2)
GUICtrlSetTip(-1, "Dev Choice #2")
GUICtrlSetCursor(-1, 0)
Global $CFS_24 = GUICtrlCreateButton("", 425, 25 + 54, 15, 15)
DefineBkFromHex(-1, $FullBlack)
GUICtrlSetTip(-1, "Perfect Black (PitchBlack)")
GUICtrlSetCursor(-1, 0)
Global $CFS_25 = GUICtrlCreateButton("", 440, 25 + 54, 15, 15)
DefineBkFromHex(-1, $FullWhite)
GUICtrlSetTip(-1, "Perfect White (FluxWhite)")
GUICtrlSetCursor(-1, 0)
; File List
Global $GUI_ColorBase_List = GUICtrlCreateList("0x000000",220,8,155,97, -1, $WS_EX_WINDOWEDGE)
GUICtrlSetFont(-1,8,900,"","Segoe UI")
GUICtrlSetData($GUI_ColorBase_List,"0xFFFFFF")
;
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
if Not FileExists(@ScriptDir & "\ColorsLocation_AutoIT.ini") Then
IniWrite(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",@ScriptDir & "\Color Base (AutoIT Version)")
EndIf
$ColorBase = IniRead(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",@ScriptDir & "\Color Base (AutoIT Version)")
if Not FileExists($ColorBase) Then
DirCreate($ColorBase)
EndIf
ColorBaseRefresh()
$NextLiveColor = GUICtrlRead($HEX)
if StringInStr($NextLiveColor,"0x","",1) Then
GUICtrlSetColor($HEX,$NextLiveColor)
GUISetBkColor($NextLiveColor)
EndIf
While 1
$nMsg = GUIGetMsg()
LiveColor()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $CFS_1
GUICtrlSetData($HEX, "0x" & $GoogleDark)
Case $CFS_2
GUICtrlSetData($HEX, "0x" & $GoogleGreen)
Case $CFS_3
GUICtrlSetData($HEX, "0x" & $GoogleRed)
Case $CFS_4
GUICtrlSetData($HEX, "0x" & $GoogleYellow)
Case $CFS_5
GUICtrlSetData($HEX, "0x" & $FacebookBlue)
Case $CFS_6
GUICtrlSetData($HEX, "0x" & $FacebookClassic)
Case $CFS_7
GUICtrlSetData($HEX, "0x" & $DiscordBluev1)
Case $CFS_8
GUICtrlSetData($HEX, "0x" & $DiscordBluev2)
Case $CFS_9
GUICtrlSetData($HEX, "0x" & $DiscordDark)
Case $CFS_10
GUICtrlSetData($HEX, "0x" & $DiscordGray)
Case $CFS_11
GUICtrlSetData($HEX, "0x" & $Buttercup)
Case $CFS_12
GUICtrlSetData($HEX, "0x" & $Ice)
Case $CFS_13
GUICtrlSetData($HEX, "0x" & $MaterialBlue)
Case $CFS_14
GUICtrlSetData($HEX, "0x" & $Win11Blue)
Case $CFS_15
GUICtrlSetData($HEX, "0x" & $MatrixGreen)
Case $CFS_16
GUICtrlSetData($HEX, "0x" & $MatrixDarkBlue)
Case $CFS_17
GUICtrlSetData($HEX, "0x" & $Espresso)
Case $CFS_18
GUICtrlSetData($HEX, "0x" & $Sand)
Case $CFS_19
GUICtrlSetData($HEX, "0x" & $Mint)
Case $CFS_20
GUICtrlSetData($HEX, "0x" & $Magenta)
Case $CFS_21
GUICtrlSetData($HEX, "0x" & $BrightPink)
Case $CFS_22
GUICtrlSetData($HEX, "0x" & $AltColor1)
Case $CFS_23
GUICtrlSetData($HEX, "0x" & $AltColor2)
Case $CFS_24
GUICtrlSetData($HEX, "0x" & $FullBlack)
Case $CFS_25
GUICtrlSetData($HEX, "0x" & $FullWhite)
Case $GUI_Menu_Options_EditCfg
$nLocation = FileSelectFolder("Select a new location for your Color Base",$ColorBase)
if $nLocation = "" Then
ColorBaseRefresh()
Else
IniWrite(@ScriptDir & "\ColorsLocation_AutoIT.ini","Colors Location","Dir",$nLocation)
$ColorBase = $nLocation
ColorBaseRefresh()
EndIf
Case $GUI_Menu_File_Remove
$tFile = GUICtrlRead($GUI_ColorBase_List)
if $tFile = "" Then
; Nothing
Else
$confirm = InputBox("Confirmation Dialog","Please confirm the deletion of this color" & @CRLF & "Target : " & $tFile & @CRLF & "Enter 'YES' to confirm and enter !","","","",150)
if $confirm = "YES" Then
FileDelete($ColorBase & "\" & $tFile)
ColorBaseRefresh()
EndIf
EndIf
Case $GUI_Menu_File_Refresh
ColorBaseRefresh()
Case $GUI_Menu_About_Dev
TyleoAbout($Prog & " Unified Edition")
Case $GUI_Menu_Color_ExportNoAutoIT
$NoITClip = GUICtrlRead($HEX)
$NoITClip = StringTrimLeft($NoITClip,2)
ClipPut($NoITClip)
Case $PickColor
$hColor = _ChooseColor(2)
if $hColor = "-1" Then
; Nothing
Else
GUISetBkColor($hColor)
GUICtrlSetBkColor($HEX,$hColor)
GUICtrlSetBkColor($GUI_ColorBase_List,$hColor)
GUICtrlSetBkColor($PickColor,$hColor)
GUICtrlSetData($HEX,$hColor)
ClipPut($hColor)
EndIf
Case $GUI_ColorBase_List
$iFileColor = GUICtrlRead($GUI_ColorBase_List)
$oFileOpen = FileOpen($ColorBase & "\" & $iFileColor & ".aucolor")
$iColor = FileRead($oFileOpen)
FileClose($oFileOpen)
GUISetBkColor($iColor)
GUICtrlSetBkColor($HEX,$iColor)
GUICtrlSetColor($HEX,0xFFFFFF)
GUICtrlSetBkColor($GUI_ColorBase_List,$iColor)
GUICtrlSetBkColor($PickColor,$iColor)
GUICtrlSetData($HEX,$iColor)
ClipPut($iColor)
Case $GUI_Menu_File_Save
$sName = InputBox("Color Human Readable Name","Enter the name of your color, You can" & @CRLF & "Choose anything.","","","",140)
$sColor = GUICtrlRead($HEX)
if $sName = "" Then
$sFileName = $sColor & ".aucolor"
Else
$sFileName = $sName & "-" & $sColor & ".aucolor"
EndIf
$sFileOpen = FileOpen($ColorBase & "\" & $sFileName,2)
FileWrite($sFileOpen,$sColor)
FileClose($sFileOpen)
ColorBaseRefresh()
Case $GUI_Menu_File_OpenBase
ShellExecute($ColorBase)
EndSwitch
WEnd
Func ColorBaseRefresh()
GUICtrlSetData($GUI_ColorBase_List,"")
$cColorFiles = _FileListToArray($ColorBase,"*.aucolor",$FLTA_FILES,False)
_ArrayDelete($cColorFiles, 0)
_ArrayTrim($cColorFiles,8,1)
$cFiles = _ArrayToString($cColorFiles)
GUICtrlSetData($GUI_ColorBase_List,$cFiles)
$cCheck = GUICtrlRead($GUI_ColorBase_List)
if $cCheck = "-1" Then
GUICtrlSetData($GUI_ColorBase_List,"")
EndIf
EndFunc
Func LiveColor()
$LiveColor = GUICtrlRead($HEX)
if $LiveColor = $NextLiveColor Then
; Nothing
Else
$NextLiveColor = GUICtrlRead($HEX)
if StringInStr($NextLiveColor,"0x","",1) Then
GUICtrlSetBkColor($HEX,$NextLiveColor)
GUICtrlSetBkColor($GUI_ColorBase_List,$NextLiveColor)
GUICtrlSetBkColor($PickColor,$NextLiveColor)
GUISetBkColor($NextLiveColor)
EndIf
EndIf
EndFunc
Func DefineBkFromHex($Target, $ColorCode)
$ColorCode = "0x" & $ColorCode
GUICtrlSetBkColor($Target, $ColorCode)
EndFunc