JohnOne Posted February 23, 2010 Share Posted February 23, 2010 (edited) Is there anyway to retrieve the current text colour of a label control, as set by GUICtrlSetColor() ? Ive doen a thorough search of help file but cannot find an answer. Just hoping that there is a solution. Appreciate any pointers. EDIT: (extra info) Its to add to this function I've been doing (live log) http://www.autoitscript.com/forum/index.php?showtopic=110023 The function srolls my code log via a GUI on the fly, and I want it to show and warnings or errors up in certain colours you see. Edited February 23, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 JohnOne,As you can see here a request for the GUICtrlGet* commands was rejected by the Devs a long time ago.I just wrote this little function, which you might find useful - although it does depend on there being some text to get the colour from: expandcollapse popup#include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $aSetColors[2] = [0xFF0000, 0x00FF00] $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("Testing", 10, 10, 100, 20) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0x00FF00) $hButton = GUICtrlCreateButton("Get Colours", 10, 50, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton $aGetColors = _GetColors($hLabel) If @error Then ConsoleWrite("No text available to read" & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) Else ConsoleWrite("Foreground: Set: " & Hex($aSetColors[0], 6) & " - Get: " & Hex($aGetColors[0], 6) & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) EndIf EndSwitch WEnd Func _GetColors($hControl) Local $aColors[2], $tpoint = DllStructCreate("int X;int Y") ; Get position of control Local $aPos = ControlGetPos($hGUI, "", $hControl) ; Convert to screen coords DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) $aPos[0] = DllStructGetData($tpoint, "X") + 1 ; Needs the added 1 to hit the first coloured pixel $aPos[1] = DllStructGetData($tpoint, "Y") + 1 ; I have no idea why ; read colour at top left - assume it is background $aColors[1] = PixelGetColor($aPos[0], $aPos[1]) ; Sweep through control to find another colour For $iX = $aPos[0] To $aPos[0] + $aPos[2] - 2 ; Again the need to adjust the coords returned by ControlGetPos For $iY = $aPos[1] To $aPos[1] + $aPos[3] - 2 ; And here too If PixelGetColor($iX, $iY) <> $aColors[1] Then ; Assume that it is text colour $aColors[0] = PixelGetColor($iX, $iY) Return $aColors EndIf Next Next ; Text colour not found, so return array, but set error as a flag $aColors[0] = 0 Return SetError(-1, 0, $aColors) EndFuncM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 Thanks M23, Superb mate. I'd have been able to do that in a couple of years time, not dared venture into dll stuff yet or winapi for that matter. Much Apreciated Amigo, will get to work trying to understand it, and apply it to my code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 (edited) JohnOne ,Big difference between direct DLL calls and the WinAPI UDF - although the latter are actually just wrappers around DLL calls themselves!The UDF is as easy to use as "normal" AutoIt functions and it offers a huge range of powers which would be very difficult to achieve with direct DLL calls by the likes of you and me. Yashied has also produced WinAPIEx.au3 to give even more access to the power of the API. The various WinAPI functions are clearly explained the Help file - give them a look over. As in this case you will realise that they are not difficult to use - but if you do not even realise that they are there..... M23Edit: I do not know why I needed that adjustment for the label position earlier - it worked as I expected when I tried it a moment ago. Just to prove it, the label can be moved around the GUI and still return the corerct values!expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MenuConstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> Global $aSetColors[2] = [0xFF0000, 0x00FF00] $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("Move Me Around", 10, 10, 100, 20) GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0x00FF00) $hButton = GUICtrlCreateButton("Get Colours", 10, 50, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYDOWN _ControlMove($hLabel) Case $hButton $aGetColors = _GetColors($hLabel) If @error Then ConsoleWrite("No text available to read" & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) Else ConsoleWrite("Foreground: Set: " & Hex($aSetColors[0], 6) & " - Get: " & Hex($aGetColors[0], 6) & _ @CRLF & "Background: Set: " & Hex($aSetColors[1], 6) & " - Get: " & Hex($aGetColors[1], 6) & @CRLF) EndIf EndSwitch WEnd Func _ControlMove($hControl) Local $aCurPos = GUIGetCursorInfo() If @error Then Return False If $aCurPos[4] = $hControl Then _SendMessage(GUICtrlGetHandle($hControl), $WM_SYSCOMMAND, BitOR($SC_MOVE, $HTCAPTION), 0) Return True EndFunc Func _GetColors($hControl) Local $aColors[2], $tpoint = DllStructCreate("int X;int Y") ; Get position of control Local $aPos = ControlGetPos($hGUI, "", $hControl) ; Convert to screen coords DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) $aPos[0] = DllStructGetData($tpoint, "X") $aPos[1] = DllStructGetData($tpoint, "Y") ; read colour at top left - assume it is background $aColors[1] = PixelGetColor($aPos[0], $aPos[1]) ; Sweep through control to find another colour For $iX = $aPos[0] To $aPos[0] + $aPos[2] - 1 For $iY = $aPos[1] To $aPos[1] + $aPos[3] - 1 If PixelGetColor($iX, $iY) <> $aColors[1] Then ; Assume that it is text colour $aColors[0] = PixelGetColor($iX, $iY) Return $aColors EndIf Next Next ; Text colour not found, so return array, but set error as a flag $aColors[0] = 0 Return SetError(-1, 0, $aColors) EndFunc Edited February 23, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 I am aware of the API fuctions in the helpfile, I just havent felt confident enough to use, them yet.Until now, the autoit built in functions have more or less provided everything I need apart from some cutsom functions.I have a feeling Im about to embark on an educational journey now though.The function you wrote above _GetColors() has a couple of problems (on my machine anyway)It very much slows down my log (by about 30x) maybe more.And (I think due to the nature of a font) does not get the correct color, so I get like a faded effect of the color I input.I was using a mouse click to test it.The bottom colour is what I origionaly set and the colours above are got from the one below it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 JohnOne, The great disadvantage of API calls is that they sometimes tend to take a bit of time to complete - relative to normal computer speed of course! Can you post your code so I can take a look? It worked correctly on my test script as you saw. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 (edited) Without colours expandcollapse popup#include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $aGuiData[20] Global $Gui Global $Newdata Func _GuiCreate(ByRef $aGuiData) $Gui = GUICreate("Test", 400, 400, 500, 100) Local $a = 0 For $i = 5 To 290 Step 15 $aGuiData[$a] = GUICtrlCreateLabel($a, 5, $i, 390, 20) $a += 1 Next GUISetState() EndFunc ;==>_GuiCreate Func _UpdateGui($Newdata) Local $temp For $i = 0 To 18 $temp = GUICtrlRead($aGuiData[$i + 1]) GUICtrlSetData($aGuiData[$i], $temp) Next GUICtrlSetData($aGuiData[19], $Newdata) EndFunc ;==>_UpdateGui _GuiCreate($aGuiData) For $i = 20 To 100 ;Sleep(60) _UpdateGui($i) Next While 1 Sleep(10) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd With colours expandcollapse popup#include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $aGuiData[20] Global $hGui Global $Newdata Global $Color = 0x000000 Func _GuiCreate(ByRef $aGuiData) $hGui = GUICreate("Test", 400, 400, 500, 100) Local $a = 0 For $i = 5 To 290 Step 15 $aGuiData[$a] = GUICtrlCreateLabel($a, 5, $i, 390, 20) $a += 1 Next GUISetState() EndFunc ;==>_GuiCreate Func _UpdateGui($Newdata, $Colour) Local $temp For $i = 0 To 18 $temp = GUICtrlRead($aGuiData[$i + 1]) $tempc = _GetColors($aGuiData[$i + 1]) GUICtrlSetData($aGuiData[$i], $temp) GUICtrlSetColor($aGuiData[$i], $tempc[0]) Next GUICtrlSetData($aGuiData[19], $Newdata) GUICtrlSetColor($aGuiData[19], $Color) EndFunc ;==>_UpdateGui _GuiCreate($aGuiData) For $i = 20 To 100 ;Sleep(60) _UpdateGui($i, $Color) Next While 1 Sleep(50) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func _GetColors($hControl) Local $aColors[2], $tpoint = DllStructCreate("int X;int Y") ; Get position of control Local $aPos = ControlGetPos($hGUI, "", $hControl) ; Convert to screen coords DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) $aPos[0] = DllStructGetData($tpoint, "X") ; Needs the added 1 to hit the first coloured pixel $aPos[1] = DllStructGetData($tpoint, "Y") ; I have no idea why ; read colour at top left - assume it is background $aColors[1] = PixelGetColor($aPos[0], $aPos[1]) ; Sweep through control to find another colour For $iX = $aPos[0] To $aPos[0] + $aPos[2] - 2 ; Again the need to adjust the coords returned by ControlGetPos For $iY = $aPos[1] To $aPos[1] + $aPos[3] - 2 ; And here too If PixelGetColor($iX, $iY) <> $aColors[1] Then ; Assume that it is text colour $aColors[0] = PixelGetColor($iX, $iY) Return $aColors EndIf Next Next ; Text colour not found, so return array, but set error as a flag $aColors[0] = 0 Return SetError(-1, 0, $aColors) EndFunc Pretty wierd. Edited February 23, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 JohnOne,It is working fine for me - the colours move up as they should. Try this "rainbow" version and see if you still have the same problem - I get the same colours in the same order throughout:expandcollapse popup#include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $aGuiData[20] Global $hGui Global $Newdata Global $aColors[7] = [0x000000, 0xFF0000, 0xFFFF00, 0x80FF80, 0x80FFFF, 0x0000FF, 0xFF00FF] Global $Color = 0x000000 Func _GuiCreate(ByRef $aGuiData) $hGui = GUICreate("Test", 400, 400, 500, 100) Local $a = 0 For $i = 0 To 19 $sText = $a & " - " & $a & " - " & $a & " - " & $a & " - " & $a $aGuiData[$a] = GUICtrlCreateLabel($sText, 5, 5 + ($i * 15), 390, 20) GUICtrlSetBkColor(-1, 0xC4C4C4) GUICtrlSetColor(-1, 0xFF0000) $a += 1 Next GUISetState() EndFunc ;==>_GuiCreate Func _UpdateGui($Newdata, $Colour) Local $temp For $i = 0 To 18 $temp = GUICtrlRead($aGuiData[$i + 1]) $tempc = _GetColors($aGuiData[$i + 1]) GUICtrlSetData($aGuiData[$i], $temp) GUICtrlSetColor($aGuiData[$i], $tempc[0]) Next $sText = $Newdata & " - " & $Newdata & " - " & $Newdata& " - " & $Newdata & " - " & $Newdata GUICtrlSetData($aGuiData[19], $sText) GUICtrlSetColor($aGuiData[19], $Color) EndFunc ;==>_UpdateGui _GuiCreate($aGuiData) For $i = 20 To 100 _UpdateGui($i, $Color) Local $iIndex = Mod($i, 7) $Color = $aColors[$iIndex] Next While 1 ;Sleep(50) ; Not needed with GUIGetMsg $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func _GetColors($hControl) Local $aColors[2], $tpoint = DllStructCreate("int X;int Y") ; Get position of control Local $aPos = ControlGetPos($hGUI, "", $hControl) ; Convert to screen coords DllStructSetData($tpoint, "X", $aPos[0]) DllStructSetData($tpoint, "Y", $aPos[1]) _WinAPI_ClientToScreen($hGUI, $tPoint) $aPos[0] = DllStructGetData($tpoint, "X") ; Needs the added 1 to hit the first coloured pixel $aPos[1] = DllStructGetData($tpoint, "Y") ; I have no idea why ; read colour at top left - assume it is background $aColors[1] = PixelGetColor($aPos[0], $aPos[1]) ; Sweep through control to find another colour For $iX = $aPos[0] To $aPos[0] + $aPos[2] - 2 ; Again the need to adjust the coords returned by ControlGetPos For $iY = $aPos[1] To $aPos[1] + $aPos[3] - 2 ; And here too If PixelGetColor($iX, $iY) <> $aColors[1] Then ; Assume that it is text colour $aColors[0] = PixelGetColor($iX, $iY) Return $aColors EndIf Next Next ; Text colour not found, so return array, but set error as a flag $aColors[0] = 0 Return SetError(-1, 0, $aColors) EndFuncOh, and I checked the running times: 2276ms if you comment out the 2 lines in _UpdateGui which deal with $tempc; 4729ms if you leave them active. So I resent the x30 times comment - it is only a factor of 2! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 lol, its most likely my computer machine, my alarm clock has a better spec.But as for the code, I get the same as before, I only see the bottom few labels before they fade out I'm stumped AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 Just been going through some of my win7 display settings and clear type text was on (must have been by default)turned it off and now its working correctly.Thank you M23 for your time, I really appreciate it. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 (edited) JohnOne,OK, a final try:Put a Sleep(5000) after the call to _GUICreate and make sure you have the original labels properly set in the GUI before you start to update them. Then put a Sleep(500) at the very beginning of your _UpdateGui function and see if you can spot where it goes wrong as you update.It is still to wet for golf, so I will be here all afternoon. I hate being bested by a lump of fused silicon with some rare earth impurities - even if it does belong to someone else! I have mine semi-tamed. M23Edit: Hurrah!!!!!! Edited February 23, 2010 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 23, 2010 Share Posted February 23, 2010 You people are weird. If you set the color yourself, you already know what color they have. I can't see why you would use the "slower than a snail" Pixel-functions. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 AdmiralAlkex, You are quite right. The original question was about getting colours from a control and I did not make the mental jump when I saw how it was to be used. Thanks for the kick! JohnOne, If you wanted to use an array, you could do it like this: expandcollapse popup#include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $aGuiData[20][2] Global $hGui Global $Newdata Global $aColors[7] = [0x000000, 0xFF0000, 0xFFFF00, 0x80FF80, 0x80FFFF, 0x0000FF, 0xFF00FF] Global $Color = 0x000000 Func _GuiCreate(ByRef $aGuiData) $hGui = GUICreate("Test", 400, 400, 500, 100) For $i = 0 To 19 $sText = $i & " - " & $i & " - " & $i & " - " & $i & " - " & $i $aGuiData[$i][0] = GUICtrlCreateLabel($sText, 5, 5 + ($i * 15), 390, 20) $aGuiData[$i][1] = $aColors[Mod($i, 7)] GUICtrlSetColor(-1, $aGuiData[$i][1]) GUICtrlSetBkColor(-1, 0xC4C4C4) Next GUISetState() EndFunc ;==>_GuiCreate Func _UpdateGui($Newdata, $NewColor) Local $temp For $i = 0 To 18 $temp = GUICtrlRead($aGuiData[$i + 1][0]) $tempc = $aGuiData[$i + 1][1] GUICtrlSetData($aGuiData[$i][0], $temp) GUICtrlSetColor($aGuiData[$i][0], $tempc) $aGuiData[$i][1] = $tempc Next $sText = $Newdata & " - " & $Newdata & " - " & $Newdata& " - " & $Newdata & " - " & $Newdata GUICtrlSetData($aGuiData[19][0], $sText) GUICtrlSetColor($aGuiData[19][0], $NewColor) $aGuiData[19][1] = $NewColor EndFunc ;==>_UpdateGui _GuiCreate($aGuiData) $iBegin = TimerInit() For $i = 20 To 100 _UpdateGui($i, $Color) Local $Color = $aColors[Mod($i, 7)] Next ConsoleWrite(TimerDiff($iBegin) & @CRLF) While 1 ;Sleep(50) ; Not needed with GUIGetMsg $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd And consign my function to the bin of history. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted February 23, 2010 Share Posted February 23, 2010 (edited) You probably think I'm reaally annoying now, but there's still some weirdness left in that. Start with the functions, they should be defined last. expandcollapse popup#include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> Global $aGuiData[20][2] Global $hGui Global $Newdata Global $aColors[7] = [0x000000, 0xFF0000, 0xFFFF00, 0x80FF80, 0x80FFFF, 0x0000FF, 0xFF00FF] Global $Color = 0x000000 _GuiCreate($aGuiData) $iBegin = TimerInit() For $i = 20 To 100 _UpdateGui($i, $Color) Local $Color = $aColors[Mod($i, 7)] Next ConsoleWrite(TimerDiff($iBegin) & @CRLF) While 1 ;Sleep(50) ; Not needed with GUIGetMsg $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func _GuiCreate(ByRef $aGuiData) $hGui = GUICreate("Test", 400, 400, 500, 100) For $i = 0 To 19 $sText = $i & " - " & $i & " - " & $i & " - " & $i & " - " & $i $aGuiData[$i][0] = GUICtrlCreateLabel($sText, 5, 5 + ($i * 15), 390, 20) $aGuiData[$i][1] = $aColors[Mod($i, 7)] GUICtrlSetColor(-1, $aGuiData[$i][1]) GUICtrlSetBkColor(-1, 0xC4C4C4) Next GUISetState() EndFunc ;==>_GuiCreate Func _UpdateGui($Newdata, $NewColor) Local $temp For $i = 0 To 18 $temp = GUICtrlRead($aGuiData[$i + 1][0]) $tempc = $aGuiData[$i + 1][1] GUICtrlSetData($aGuiData[$i][0], $temp) GUICtrlSetColor($aGuiData[$i][0], $tempc) $aGuiData[$i][1] = $tempc Next $sText = $Newdata & " - " & $Newdata & " - " & $Newdata& " - " & $Newdata & " - " & $Newdata GUICtrlSetData($aGuiData[19][0], $sText) GUICtrlSetColor($aGuiData[19][0], $NewColor) $aGuiData[19][1] = $NewColor EndFunc ;==>_UpdateGui There's also a lot of flickering with the background, but I'm to hungry (??) to see why. It would probably be better to use GDI+ or SDL for graphical things. Or remove the GUICtrlSetBkColor(), it looks a lot better, but then the light colors get hard to read. Edited February 23, 2010 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 AdmiralAlkex, Not annoying........just a bit picky, perhaps! Anyway, if you want to rewrite JohnOne's script, be my guest. I tend only to change things in others' scripts which would cause a real problem. Oh, and the rainbow colours and background were a short-term fix by me to help watch the labels swap. I do not think the OP intends to keep them - at least for his eyes' sake I hope not! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Yashied Posted February 23, 2010 Share Posted February 23, 2010 Is there anyway to retrieve the current text colour of a label control, as set by GUICtrlSetColor()?Maybe this? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 23, 2010 Moderators Share Posted February 23, 2010 Yashied,Maybe this?Makes my head hurt just to look at it! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted February 23, 2010 Author Share Posted February 23, 2010 (edited) Maybe this?In the example codes given in the thread, none return the correct text colour or Ctrlbkcolor.The last example where the gui background is returned works, but the text colour is returned as "0x000000", when infact it has been set to "GUICtrlSetColor(-1, 0xFF0000)".I wonder if that could have something to do with my display setting, having turned off clear type.EDIT: same with clear type on. Edited February 23, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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