Jump to content

Recommended Posts

Posted

Hi,

Has anyone ever tried to change the text color of an input box after a button click? The text will be black when the user enters it and it turns green after theu click the button.

I have been trying to this using "$nColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)"

I was thinking of something like this:

include <GUIConstants.au3>

; GUI
$GUI1 = GUICreate(" tasks", 400, 175)
GUICtrlSetColor(-1, 0xFB1409)

; InputBox
$ipbox = GUICtrlCreateInput("Enter", 50, 50, 90, 20)

$Button1r1 = GUICtrlCreateButton("Web", 10, 100, 85, 30)

$newColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)

GUISetState(@SW_SHOW)

;R1
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $Button1r1, $ipbox
            $data = StringStripWS(GUICtrlRead($ipbox), 3);$data is the contents of the input, but remove leading and trailng spaces
            $newColor = DllCall("gdi32.dll", "int", "SetTextColor", "hwnd", $hDC, "int", $nColor)

       ;ConsoleWrite($data & @CRLF)
            Select
                If Case $data = "gmail" Then
            $newColor
                    ShellExecute("http://www.gmail.com")
        Else
                Case $data = "exit"
                    _Exit()
        EndIf
            EndSelect

        Case $GUI_EVENT_CLOSE
            _Exit()
    EndSwitch
WEnd

Func _Exit()
    Exit
EndFunc  ;==>_Exit

GUIDelete()
Posted (edited)

the script will not work... you need to script right first, make it one step after another, first you need to have a working GUI after that you set the events and there will see...

well i end it scripting for you... next time try to learn first for the beggining. and use the tidy tool of scite to make your script more readeable.(for us)

#include <GUIConstants.au3>

$GUI1 = GUICreate(" tasks", 400, 175)
GUICtrlSetColor(-1, 0xFB1409)
$ipbox = GUICtrlCreateInput("Enter", 50, 50, 90, 20)
$Button1r1 = GUICtrlCreateButton("Web", 10, 100, 85, 30)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _Exit()
        Case $Button1r1
            Guictrlsetcolor($ipbox,0xff0000)
    EndSwitch
WEnd

Func _Exit()
    Exit
EndFunc  ;==>_Exit
Edited by monoscout999

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
  • Recently Browsing   0 members

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