mdwerne Posted November 28, 2012 Share Posted November 28, 2012 Hello, I was wondering if there was a way to set the color of a variable so that wherever in my GUI I put that variable, it was that color. In the example below, I'd like to set $BitNess to be red no matter where in the GUI I place it. Possible without stacking the GUICtrlCreateLabel tags? Hopefully my ramblings make sense. For example: expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=net.ico #AutoIt3Wrapper_Outfile=Installer.exe #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include Global $gui, $guiPos, $pic, $picPos $CurrentOS = _GetOSVersion() InstallerGUI() Func _GetOSVersion() Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Local $colSettings = $objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For $objOperatingSystem In $colSettings Return "Windows " & StringMid($objOperatingSystem.Caption, 19) Next EndFunc ;==>_GetOSVersion Func InstallerGUI() Local $n, $msg GUICreate("Installer", 300, 200, -1, -1) $n = GUICtrlCreatePic("Installer.bmp", 0, 0, 300, 200, $WS_EX_TRANSPARENT) If @OSArch = "X86" Then $BitNess = "32bit" GUICtrlSetColor(-1, 0xff0000) ;I realize this is bad code. This is what I'm after without stacking GUICtrlCreateLabel tags on the same line. ElseIf @OSArch = "X64" Then $BitNess = "64bit" GUICtrlSetColor(-1, 0xff0000) ;I realize this is bad code. This is what I'm after without stacking GUICtrlCreateLabel tags on the same line. EndIf GUICtrlCreateGroup("", 10, 5, 280, 95) GUICtrlCreateLabel("OS Detected: " & $CurrentOS & " " & $BitNess, 20, 20, 200, 25) GUICtrlCreateLabel("Program " & $BitNess & " will be installed", 20, 40, 200, 25) $bContinue = GUICtrlCreateButton("Continue", 60, 63, 75) $bCancel = GUICtrlCreateButton("Cancel", 170, 63, 75) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $bCancel ExitLoop Case $msg = $bContinue GUISetState(@SW_HIDE) MsgBox(0, 'Testing', 'Installer) ExitLoop EndSelect WEnd GUIDelete() EndFunc ;==>InstallerGUI I did search the help and the forums and the web, maybe my internal search engine is broken, but I could not find what I'm after. Thanks for any suggestions, -Mike Link to comment Share on other sites More sharing options...
water Posted November 28, 2012 Share Posted November 28, 2012 You do not set the color of a variable, you set the color of a control (text color, background color ...). Have a look at the example script of function GUICtrlSetColor. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JohnOne Posted November 28, 2012 Share Posted November 28, 2012 Might be possible in a richedit control, but I wouldn't know how. 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...
mdwerne Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) Thanks for the quick reply water. And thanks for the clarification of what actually gets set. I've used GUICtrlSetColor before for an entire line, but the only way to do what I'm after is by using GUICtrlSetColor in the following way: GUICtrlCreateLabel("Black text", 10, 20) GUICtrlCreateLabel($BitNess,40, 20) GUICtrlSetColor(-1, 0xff0000) ; Red GUICtrlCreateLabel("more Black text", 70, 20) This is what I was talking about when I mentioned stacking GUICtrlCreateLabel tags on the same line. Doing it this method I can never get the text spacing on the line correct between different machines...so sometimes $BitNess is closer to the text, sometimes it's further. I apologize if I'm further confusing the issue. Hope this post helped. -Mike Edited November 28, 2012 by mdwerne Link to comment Share on other sites More sharing options...
water Posted November 28, 2012 Share Posted November 28, 2012 If I understand you correctly you would like to create ONE label control and mark a word in the text of the Control in a different color like: "Your OS runs 64 bit more black text" My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mdwerne Posted November 28, 2012 Author Share Posted November 28, 2012 If I understand you correctly you would like to create ONE label control and mark a word in the text of the Control in a different color like: "Your OS runs 64 bit more black text"That is correct, the only caveat being that the one word may show up multiple times and in multiple locations in the same GUI (different tabs, different lines, etc...).-Mike Link to comment Share on other sites More sharing options...
water Posted November 28, 2012 Share Posted November 28, 2012 Maybe helps. Haven't tested or used it myself. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mdwerne Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) Maybe helps. Haven't tested or used it myself.On the surface this looks to be exactly what I'm after!I'd love to know what you typed in the search to find this...or if you just rememberred it from MrCreatoR's original post.Thank you for the help and for being my search engine... -Mike Edited November 28, 2012 by mdwerne Link to comment Share on other sites More sharing options...
water Posted November 28, 2012 Share Posted November 28, 2012 IIRC I was looking for "label set color text". The link I posted was near the end of result page 1. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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