Merrik Posted June 30, 2011 Share Posted June 30, 2011 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: expandcollapse popupinclude <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() Link to comment Share on other sites More sharing options...
JohnOne Posted June 30, 2011 Share Posted June 30, 2011 Does it work? I thought you could not change a input control colour, and you need to use a richedit control. 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...
monoscout999 Posted June 30, 2011 Share Posted June 30, 2011 (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 June 30, 2011 by monoscout999 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