Alek Posted March 17, 2007 Posted March 17, 2007 I got a bit bored and i made a GUI with 3 progressbarsliders that alows you to change the background color. expandcollapse popup#include <GuiConstants.au3> $gui = GuiCreate("Color handler", 390, 140,-1, -1) $Progress_1 = GuiCtrlCreateProgress(10, 10, 330, 20) $Progress_2 = GuiCtrlCreateProgress(10, 40, 330, 20) $Progress_3 = GuiCtrlCreateProgress(10, 70, 330, 20) $Label_4 = GuiCtrlCreateLabel("Red", 350, 10, 50, 20) GUICtrlSetColor($Label_4,0xff0000) $Label_5 = GuiCtrlCreateLabel("Green", 350, 40, 60, 20) GUICtrlSetColor($Label_5,0x00ff00) $Label_6 = GuiCtrlCreateLabel("Blue", 350, 70, 50, 20) GUICtrlSetColor($Label_6,0x0000ff) $Button_7 = GUICtrlCreateButton("Test",10,100,50,30) GuiSetState() do sliderprobar($Progress_1, 3) sliderprobar($Progress_2, 4) sliderprobar($Progress_3, 5) setcolor() $msg = GuiGetMsg() if $msg = $Button_7 then GUISetBkColor("0x" & $color) until $msg = $GUI_EVENT_CLOSE Exit Func sliderprobar($prog_name, $prog_ID) $a=GUIGetCursorInfo() $cpos = ControlGetPos($gui,"",$prog_name) if $a[4] = $prog_ID and _IsPressed("01") then $t = $cpos[2]/100 guictrlsetdata($prog_name, $a[0]/$t-2) EndIf EndFunc Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc Func setcolor() $hexnum1 = (255/100)*GUICtrlRead($Progress_1) $num1 = hex($hexnum1,2) $hexnum2 = (255/100)*GUICtrlRead($Progress_2) $num2 = hex($hexnum2,2) $hexnum3 = (255/100)*GUICtrlRead($Progress_3) $num3 = hex($hexnum3,2) Global $color = (0x & $num1 & $num2 & $num3) EndFunc and when i got it working i couldent find any use for it so I posted it her hopeing that maybe some1 could use it. [font="Impact"]Never fear, I is here.[/font]
Moderators SmOke_N Posted March 17, 2007 Moderators Posted March 17, 2007 Nice job... this may let you look at things a bit differently... just follow your code then follow mine... I tried to keep it relative to what you had (excluded the test button though)CODEexpandcollapse popup#include <GuiConstants.au3> Global $Progress[4] $gui = GuiCreate("Color handler", 390, 140,-1, -1) $Progress[1] = GuiCtrlCreateProgress(10, 10, 330, 20) $Progress[2] = GuiCtrlCreateProgress(10, 40, 330, 20) $Progress[3] = GuiCtrlCreateProgress(10, 70, 330, 20) $Label_4 = GuiCtrlCreateLabel("Red", 350, 10, 50, 20) GUICtrlSetColor($Label_4,0xff0000) $Label_5 = GuiCtrlCreateLabel("Green", 350, 40, 60, 20) GUICtrlSetColor($Label_5,0x00ff00) $Label_6 = GuiCtrlCreateLabel("Blue", 350, 70, 50, 20) GUICtrlSetColor($Label_6,0x0000ff) GuiSetState() While GUIGetMsg() <> -3 For $iCC = 1 To 3 If sliderprobar($Progress[$iCC], $Progress[$iCC]) Then GUISetBkColor(setcolor()) Next WEnd Func sliderprobar($prog_name, $prog_ID) $aCPos = GUIGetCursorInfo() $cpos = ControlGetPos($gui,"",$prog_name) if $aCPos[4] = $prog_ID and _IsPressed("01") Then GUICtrlSetData($prog_name, $aCPos[0]/($cpos[2]/100)-2) Sleep(100) Return 1 EndIf Return 0 EndFunc Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc Func setcolor() Local $hexnum, $nnum For $iCC = 1 To 3 $hexnum = (255/100)*Number(GUICtrlRead($Progress[$iCC])) $nnum &= Hex($hexnum, 2) Next Return Execute('0x' & $nnum) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Valuater Posted March 17, 2007 Posted March 17, 2007 Might as well give use of the color to the user... lol expandcollapse popup#include <GuiConstants.au3> Global $Progress[4], $C_set = 0 $gui = GUICreate("Color handler", 390, 140, -1, -1) GUISetBkColor(0x00FC00, $gui) ; *********** for testing $Progress[1] = GUICtrlCreateProgress(10, 10, 330, 20) $Progress[2] = GUICtrlCreateProgress(10, 40, 330, 20) $Progress[3] = GUICtrlCreateProgress(10, 70, 330, 20) $Label_4 = GUICtrlCreateLabel("Red", 350, 10, 50, 20) GUICtrlSetColor($Label_4, 0xff0000) $Label_5 = GUICtrlCreateLabel("Green", 350, 40, 60, 20) GUICtrlSetColor($Label_5, 0x00ff00) $Label_6 = GUICtrlCreateLabel("Blue", 350, 70, 50, 20) GUICtrlSetColor($Label_6, 0x0000ff) $Label_7 = GUICtrlCreateLabel("", 50, 110, 350, 20) GUISetState() While GUIGetMsg() <> -3 For $iCC = 1 To 3 If sliderprobar($Progress[$iCC], $Progress[$iCC]) Then GUISetBkColor(setcolor()) Next WEnd Func sliderprobar($prog_name, $prog_ID) $aCPos = GUIGetCursorInfo() $cpos = ControlGetPos($gui, "", $prog_name) If $aCPos[4] = $prog_ID And _IsPressed("01") Then GUICtrlSetData($prog_name, $aCPos[0]/ ($cpos[2] / 100) - 2) Sleep(100) Return 1 EndIf Return 0 EndFunc ;==>sliderprobar Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed Func setcolor() Local $hexnum, $nnum For $iCC = 1 To 3 $hexnum = (255 / 100) * Number(GUICtrlRead($Progress[$iCC])) $nnum &= Hex($hexnum, 2) Next GUICtrlSetData($Label_7, "The color copied to the clipboard is... " & (('0x' & $nnum))) ClipPut('0x' & $nnum) Return Execute('0x' & $nnum) EndFunc ;==>setcolor 8)
Moderators SmOke_N Posted March 17, 2007 Moderators Posted March 17, 2007 I thought about adding the hue sat etc... but to be honest, I was too lazy, and didn't think to simplify it by adding a label I do like how when used as I re-arranged it, you can treat it like a slider on the progressbar Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
_Kurt Posted March 17, 2007 Posted March 17, 2007 Although this script may be a little simple, I really like it. I think it's clever and could be useful for picking out some colors Kurt Awaiting Diablo III..
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