Jump to content
Sign in to follow this  
zoel

Font collor

Recommended Posts

Hi people, I have some text when I run some commands and I want that text to be  white . I put it like this but the text still stays black, any hints?

Local $idInput = GUICtrlCreateEdit("", 168, 34, 921, 465)
GUICtrlSetFont(-1, 10, 400, 0, "Courier")
GUICtrlSetBkColor(-1, 0x0000FF)

here is my whole code

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GUIToolTip.au3>
#include <WinAPIDlg.au3>
Local $aWndPos
Local $vDos, $sline = ""
$NetAs = GUICreate("NetAs-Network Assistant", 1096, 521, 182, 135)
Local $idFilemenu = GUICtrlCreateMenu("&File")
Local $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu)
Local $idSaveitem = GUICtrlCreateMenuItem("Save", $idFilemenu)
Local $idInput = GUICtrlCreateEdit("", 168, 34, 921, 465)
GUICtrlSetFont(-1, 10, 400, 0, "Courier")
GUICtrlSetBkColor(-1, 0x0000FF)
Local $Button1 = GUICtrlCreateButton("IPconfig", 48, 56, 75, 25)
Local $Button3 = GUICtrlCreateButton("FlushDNS", 48, 96, 75, 25)
Local $Button5 = GUICtrlCreateButton("ConnRelease", 48, 136, 75, 25)
Local $Button7 = GUICtrlCreateButton("NetStat", 48, 176, 75, 25)
Local $Button9 = GUICtrlCreateButton("Route Print", 48, 216, 75, 25)
Local $Button11 = GUICtrlCreateButton("ARP", 48, 256, 75, 25)
Local $Button13 = GUICtrlCreateButton("NSLookup", 48, 296, 75, 25)
Local $Button15 = GUICtrlCreateButton("NetStat -an", 48, 336, 75, 25)
Local $Button17 = GUICtrlCreateButton("GetMac", 48, 376, 75, 25)
Local $Button19 = GUICtrlCreateButton("Ping", 48, 416, 75, 25)
Local $Button23 = GUICtrlCreateButton("Run", 656, 8, 73, 25)
Local $Button24 = GUICtrlCreateButton("Clear", 576, 8, 75, 25)

Local $Input1 = GUICtrlCreateInput("", 736, 8, 345, 21)
GUISetState(@SW_SHOW)
$hENTER = GUICtrlCreateDummy()
Dim $AccelKeys[1][2] = [["{ENTER}", $hENTER]] ; Set accelerators
GUISetAccelerators($AccelKeys)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idExititem
            Exit
        Case $Button1
            GUICtrlSetData($idInput, _CmdInfo() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button3
            GUICtrlSetData($idInput, _CmdInfo2() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button5
            GUICtrlSetData($idInput, _CmdInfo3() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button7
            GUICtrlSetData($idInput, _CmdInfo4() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button9
            GUICtrlSetData($idInput, _CmdInfo5() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button11
            GUICtrlSetData($idInput, _CmdInfo6() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button13
            GUICtrlSetData($idInput, _CmdInfo7() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button15
            GUICtrlSetData($idInput, _CmdInfo8() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button17
            GUICtrlSetData($idInput, _CmdInfo9() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button19
            GUICtrlSetData($idInput, _CmdInfo10() & @CRLF)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
            _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET)
        Case $Button24
                GUICtrlSetData($idInput, "")
        Case $Button23, $hENTER
                $vDos = Run(@ComSpec & " /c " & GUICtrlRead($Input1), @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
                While 1
                    $sline &= StdoutRead($vDos)
                    If @error Then ExitLoop
                WEnd
                GUICtrlSetData($idInput, $sline & @CRLF)
                GUICtrlSetData($Input1, "")
                ;----> Reset
                $sline = ""
    EndSwitch
WEnd



Func _CmdInfo($_sCmdInfo = "ipconfig /all")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo2($_sCmdInfo2 = "IPConfig /FlushDNS")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo2, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo3($_sCmdInfo3 = "IPConfig /Release")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo3, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo4($_sCmdInfo4 = "NetStat")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo4, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo5($_sCmdInfo5 = "Route Print")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo5, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo6($_sCmdInfo6 = "ARP -a")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo6, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo7($_sCmdInfo7 = "NSLookup")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo7, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo8($_sCmdInfo8 = "netstat -an")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo8, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo9($_sCmdInfo9 = "getmac")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo9, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc
Func _CmdInfo10($_sCmdInfo10 = "ping google.com")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo10, "", @SW_HIDE,  BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc

 

Share this post


Link to post
Share on other sites

@zoel

If only you looked more carefully in the Help file, you could see that GUICtrlSetBkColor() sets the Background color of the control as it suggests the function name.

You have to use GUICtrlSetColor() to set the control's font color.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

my 2 cents :) 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>
#include <GUIToolTip.au3>
#include <WinAPIDlg.au3>
#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
Global $aWndPos
Global $vDos, $sline = "" ; all these are a mess. The GUI looks better in a func, but, you'll choose better as you gain experience  ;)
Global $NetAs = GUICreate("NetAs-Network Assistant", 1096, 521, 182, 135)
Global $idFilemenu = GUICtrlCreateMenu("&File")
Global $idExititem = GUICtrlCreateMenuItem("Exit", $idFilemenu)
Global $idSaveitem = GUICtrlCreateMenuItem("Save", $idFilemenu)
Global $idInput = GUICtrlCreateEdit("", 168, 34, 921, 465)
GUICtrlSetFont(-1, 10, 400, 0, "Courier")
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetColor(-1, 0x00FFFF)

Global $Button19 = GUICtrlCreateButton("Ping", 48, 416, 75, 25)
Global $Button23 = GUICtrlCreateButton("Run", 656, 8, 73, 25)
Global $Button24 = GUICtrlCreateButton("Clear", 576, 8, 75, 25)

Global $Input1 = GUICtrlCreateInput("ping google.com", 736, 8, 345, 21)
GUISetState(@SW_SHOW)
Global $hENTER = GUICtrlCreateDummy()
Global $AccelKeys[1][2] = [["{ENTER}", $hENTER]] ; Set accelerators
GUISetAccelerators($AccelKeys)

main()
Func main()
    Local $sline, $vDos, $nMsg
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE, $idExititem
                GUIDelete($NetAs)
                Exit 0

            Case $Button19
                bttnState($GUI_DISABLE) ; no duble click or concurrent run
                GUICtrlSetData($idInput, ' ..pinging, this will take a moment.. ') ; let the user know wassup.
                GUICtrlSetData($idInput, _CmdInfo10() & @CRLF)
                _GUICtrlEdit_Scroll($idInput, $SB_SCROLLCARET) ; once is ok
                bttnState($GUI_ENABLE)

            Case $Button24
                GUICtrlSetData($idInput, "")

            Case $Button23, $hENTER
                bttnState($GUI_DISABLE) ; no duble click or concurrent run
                $vDos = Run(@ComSpec & " /c " & GUICtrlRead($Input1), @TempDir, @SW_HIDE, $STDERR_MERGED)
                While 1
                    $sline &= StdoutRead($vDos)
                    If @error Then ExitLoop
                    If GUICtrlRead($idInput) <> $sline Then GUICtrlSetData($idInput, $sline) ; I like it this way  =)
                WEnd
                GUICtrlSetData($idInput, $sline & @CRLF)
;~             GUICtrlSetData($Input1, "")
                ;----> Reset
                $sline = ""
                bttnState($GUI_ENABLE)

        EndSwitch
    WEnd
EndFunc   ;==>main

Func bttnState($iState)
    GUICtrlSetState($Button19, $iState)
    GUICtrlSetState($Button23, $iState)
    GUICtrlSetState($Button24, $iState)
    GUICtrlSetState($Input1, $iState)
EndFunc   ;==>bttnState

Func _CmdInfo10($_sCmdInfo10 = "ping google.com")
    Local $iPID = Run(@ComSpec & " /c " & $_sCmdInfo10, "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD))
    ; Wait until the process has closed using the PID returned by Run.
    ProcessWaitClose($iPID)
    ; Read the Stdout stream of the PID returned by Run. This can also be done in a while loop. Look at the example for StderrRead.
    Local $sOutput = StringReplace(StdoutRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sOutErr = StringReplace(StderrRead($iPID), @CRLF & @CRLF, @CRLF)
    Local $sReult = $sOutput <> "" ? $sOutput : $sOutErr
    Return $sReult
EndFunc   ;==>_CmdInfo10

 

Edited by argumentum
i liked this code better, so I edit it, again and again and ...

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...