quickbeam Posted October 18, 2016 Posted October 18, 2016 I have a status line in my GUI that has various messages, but has green text when things are good and red otherwise. I was hoping to avoid keeping another state variable around and just read back the color when I need to know the status. AutoIT internally must know the color of what you set it to, but there doesn't seem to be a way to get to it? I saw this thread, but that's about the background color, and is definitely a long way to get there: Is there an easy solution, or should I just bite the bullet and add a line to update a new state variable every place the status is updated? Thanks
spudw2k Posted October 18, 2016 Posted October 18, 2016 (edited) What in your script dictates/sets the color of the text? What kind of control is it (label)? Are you able to post a reproducer/demo script? edit: Without testing, this seems plausible Couldn't get this to work. #include <WinAPI.au3> #include <WinAPIGdi.au3> Func GUICtrlGetTextColor($hWnd) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local $hDC = _WinAPI_GetDC($hWnd) Local $iColor = _WinAPI_GetTextColor($hDC) _WinAPI_ReleaseDC($hWnd, $hDC) Return $iColor EndFunc Found another example on the forum, but it's also a bit complicated (requires registermsg) and I get get that one to work either... Edited October 18, 2016 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
quickbeam Posted October 19, 2016 Author Posted October 19, 2016 Sorry. I was just using GuiCtrlSetColor() to set the color on a label, then hoping for an easy way to retrieve it later. I see GUICtrlGetHandle, but I'm not sure what you can do with a handle. (I'm kind of new to the whole AutoIT world - I'm using it as an easy tool to test out my embedded program on a USB device, and definitely not a Windows expert). Too bad that example didn't work, it looks promising.
spudw2k Posted October 19, 2016 Posted October 19, 2016 Yea, drag. So I'm not sure where to go from here in regards to retrieving the control color. If it were me I'd just track the state/value/what-have-you when you apply the color in a global variable. Seems just as effective to me...but I'm probably not seeing the entire picture here. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
quickbeam Posted October 20, 2016 Author Posted October 20, 2016 You're right, tracking the state is the easiest solution. It's no deal-breaker, I can keep going. I'm just not that familiar with the language yet, so I assumed if you can set something, there exists a complementary function to get that value. That does not seem to be the case. I know when I write Python code, it looks like a C programmer wrote it. I'm trying to avoid that here.
kylomas Posted October 20, 2016 Posted October 20, 2016 quickbeam, A color state var is probably the easiest solution, however, M23 came up with this solution to the same question. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
quickbeam Posted October 21, 2016 Author Posted October 21, 2016 Yowzers. A state variable it is. Good to know the question has been researched before!
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