Jump to content

Get Font Color


Recommended Posts

I am trying to get the font color function setup but not able to get after multiple attempts also.

What I want is when any of the Step actions are completed, it would display msgbox with the status. The Status action Function is assigned at the end.

Now I wanted if the msgbox displays Value1: Failed then the Failed word should show in Green. and if it's Passed the the Passed  should be Green in color.

Now after trying a lot with different ways, I understand that this might not be possible with just a normal msgbox. I even checked with _ExtMsgBox funtions but it did not helped here.

I can try to get the $Failed = 'Failed' and $Passed = 'Passed' assigned initiattly and call that inside the function. But that also did not work.

I believe GUICtrlSetColor($Install, $COLOR_GREEN) and GUICtrlSetColor($Install, $COLOR_RED) but for that I have to prepare the Func Final() in a different way which I am not able to do.

Is there anyways you can help me here?

 

#Region
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <process.au3>
#include <IE.au3>
#include <Array.au3>
#include <Constants.au3>

Global $InstallEvent, $Value1, $Value2


#Region
$Form1 = GUICreate("Form1", 388, 241, 750, 360)
$Step1 = GUICtrlCreateLabel("Step 1", 32, 40, 42, 20)
$Step2 = GUICtrlCreateLabel("Step 3", 216, 40, 42, 20)
$Step3 = GUICtrlCreateLabel("Step 2", 120, 40, 42, 20)
$Step4 = GUICtrlCreateLabel("Step 4", 312, 40, 42, 20)
$Input_Text = GUICtrlCreateInput("", 48, 104, 289, 24)
$OK = GUICtrlCreateButton("OK", 152, 176, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion

OnAutoItExitRegister("Process_Terminated")

While 1
    $nMsg = GUIGetMsg()
    $aInfo = GUIGetCursorInfo($Form1)
    If $aInfo[2] Then
        If $aInfo[4] = $Input_Text Then GUICtrlSetData($Input_Text, "")
    EndIf

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit


        Case $OK
            Select
                Case GUICtrlRead($Input_Text) = '1'
                    ; Running multiple functions
                    SplashTextOn("Step 1", "Running multiple functions under Step 1.", 275, 100, -1, -1, "Verdana")
                    CreateLog() ; Set up Log file
                    Sleep(1000)
                    SplashOff()
                    MsgBox(0, "Final", $Value1 & @CRLF & $Value2)

                Case GUICtrlRead($Input_Text) = '2'
                    ; Running multiple functions
                    SplashTextOn("Step 2", "Running multiple functions under Step 2.", 275, 100, -1, -1, "Verdana")
                    CreateLog() ; Set up Log file
                    Sleep(1000)
                    SplashOff()
                    MsgBox(0, "Final", $Value1 & @CRLF & $Value2)

                Case GUICtrlRead($Input_Text) = '3'
                    ; Running multiple functions
                    SplashTextOn("Step 3", "Running multiple functions under Step 3.", 275, 100, -1, -1, "Verdana")
                    CreateLog() ; Set up Log file
                    Sleep(10000)
                    SplashOff()
                    MsgBox(0, "Final", $Value1 & @CRLF & $Value2)

                Case GUICtrlRead($Input_Text) = '4'
                    ; Running multiple functions
                    SplashTextOn("Step 3", "Running multiple functions under Step 3.", 275, 100, -1, -1, "Verdana")
                    CreateLog() ; Set up Log file
                    Sleep(10000)
                    SplashOff()
                    Final()
                    MsgBox(0, "Final", $Value1 & @CRLF & $Value2)
            EndSelect
    EndSwitch
WEnd

Func CreateLog()
    ; Creating Logs
    Global $InstallFolder = @ScriptDir ; Create the Log file in this folder
    Global $InstallEvent = $InstallFolder & "\" & "Process.log"
    _FileCreate($InstallEvent)
EndFunc   ;==>CreateLog

Func Process_Terminated()
    Switch @exitMethod
        ;Case 0
        ;   _FileWriteLog($InstallEvent, "Natural closing.")
        Case 1
            _FileWriteLog($InstallEvent, "close by Exit function.")
        Case 2
            _FileWriteLog($InstallEvent, "close by clicking on exit of the systray.")
        Case 3
            _FileWriteLog($InstallEvent, "close by user logoff.")
        Case 4
            _FileWriteLog($InstallEvent, "close by Windows shutdown.")
    EndSwitch
EndFunc   ;==>Process_Terminated

Func Final()
    Select
        Case Not ProcessExists("ProcessName")
            $Value1 = "Value 1: Failed"
        Case Else
            $Value1 = "Value 1: Passed"
    EndSelect


    Select
        Case Not FileExists("Program Name")
            $Value2 = "Value 2:     Failed"
        Case Else
            $Value2 = "Value 2:     Passed"
    EndSelect
EndFunc   ;==>Final

 

Link to comment
Share on other sites

MsgBox doesn't support the setting of colors.
You could either create your own child GUI to display the colored message or use the ExtMsgBox UDF written by Melba23.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I have already been trying to see if a child GUI will help but not able to get that and have already checked the _Extended msgbox of Melba which looks what I a, looking for but not able to understand how to get it started. :(

Link to comment
Share on other sites

  • Moderators

sunshinesmile84,

Not too difficult to get what you want:

#include "ExtMsgBox.au3"

_ExtMsgBoxSet(0, Default, Default, 0xFF0000) ; Set text to red


_ExtMsgBox($EMB_ICONINFO, "OK", "Font colour", "I am in RED")

_ExtMsgBoxSet(0, Default, Default, 0x00FF00) ; Set text to green


_ExtMsgBox($EMB_ICONINFO, "OK", "Font colour", "I am in GREEN")

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

hey Melba23, thank you for replying.

This is what I am getting.

$EMB_ICONINFO was giving variable not declared which went off after getting it at the top but others not. I think "ExtMsgBox.au3" is not getting recognized on mine.

Link to comment
Share on other sites

  • Moderators

sunshinesmile84,

Have you downloaded the ExtMsgBox UDF from the link in my sig and placed it in the same folder as the script?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Got it now.

Let me check how I can use this on my code. This thing is, I want only the word Failed or Passed to be colored and not the complete line.

Thanks for your help. Will disturb you again if any issues.  :)

Link to comment
Share on other sites

  • Moderators

sunshilesmile84,

 I want only the word Failed or Passed to be colored and not the complete line

Then you will need to create your own dialog and use separate labels - is it really worth the extra effort?

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Why color single words? That's eye candy. 

Wouldn't MsgBox do the same? Set the flags and you will get error, information or abort icons. 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yes, the code I have written needs to have it differentiated like that. I am at the end of my work but stuck with just this part since long time. :(

This is what I wanted. There are many Steps that would be displayed but as an example I am just shown 2 lines here.

Step 1: Passed

Step 2: Failed

Status.jpg

Link to comment
Share on other sites

I want single words coz, I have written the function as:

So, when the msgbox is called after the step 1 or 2 or 3 or 4, it would display the msgbox either of the 2: Value 1:  Passed / Failed

 

Func Final()
    Select
        Case Not ProcessExists("ProcessName")
            $Value1 = "Value 1:    Failed"
        Case Else
            $Value1 = "Value 1:    Passed"
    EndSelect


    Select
        Case Not FileExists("Program Name")
            $Value2 = "Value 2:        Failed"
        Case Else
            $Value2 = "Value 2:        Passed"
    EndSelect
EndFunc   ;==>Final

Edited by sunshinesmile84
Link to comment
Share on other sites

Couldn't you just use upper case and spaces? So "Failed" becomes "F A I L E D"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I was actually planning to also keep the Func like this.

So is there anything could be done with this $Failed  and $Passed as per your UDF and it could be added in the below function.

Or if a new GUI could be created which will only get active when the MsgBox is called after the steps performed.

I know I am asking more time from you and would appreciate your help.

 

$Failed = 'Failed'
$Passed = 'Passed'

Func Final()
    Select
        Case Not ProcessExists("ProcessName")
            $Value1 = "Value 1:    " & $Failed
        Case Else
            $Value1 = "Value 1:    " & $Passed
    EndSelect


    Select
        Case Not FileExists("Program Name")
            $Value2 = "Value 2:        " & $Failed
        Case Else
            $Value2 = "Value 2:        " & $Passed
    EndSelect
EndFunc   ;==>Final

 

Link to comment
Share on other sites

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 615, 438, 192, 124)


GUICtrlCreateLabel("Step 1:",10,10,400,25)
GUICtrlSetFont(-1,16,600,"","Comic Sans MS")
$LBL_Value1 = GUICtrlCreateLabel("",110,10,300,25)
GUICtrlSetFont(-1,16,600,"","Comic Sans MS")

$BTN_Start = GUICtrlCreateButton("Start",300,300,300,100)
GUICtrlSetFont(-1,16,600,"","Comic Sans MS")

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $BTN_Start
            If Random(0,1,1) = 1 Then
                GUICtrlSetData($LBL_Value1,"Congratulations! You are the 1000th visitor! You won!")
                GUICtrlSetColor($LBL_Value1,0x00FF00)
            Else
                GUICtrlSetData($LBL_Value1,"FAIL")
                GUICtrlSetColor($LBL_Value1,0xFF0000)
            EndIf
    EndSwitch
WEnd

 

Then you will need to create your own dialog and use separate labels - is it really worth the extra effort?

Edited by GordonFreeman
Link to comment
Share on other sites

This is not working out...  :sweating:

I know it might be frustrating you too.  Thank you everyone who gave time for me. Really appreciate.

I will have to keep searching how to get this done though. :(

 

Link to comment
Share on other sites

Why color single words? That's eye candy. 

Wouldn't MsgBox do the same? Set the flags and you will get error, information or abort icons. 

​@water

 The reason I do not want to use the msgbox Flag for abort or retry because teh code I have written does lots of tasks. At the end it will re-check all the work performed and then will throw the msgbox with the results which of then got Passed and which programs got failed. Now we needed the Passed and Failed words to be shown with colors so as to better identify them. :)

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...