Tiboi Posted June 6, 2010 Share Posted June 6, 2010 (edited) ok this is what i want to do: i want a user to be entering text into textbox2 and while the user press the keys the box will be checking to see if the text in it is the same as the text in textbox1. if it is then the box will be green if not it will be red here is the code i have so far: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input2 $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf EndSwitch WEnd please help or point me to somewhere that i can get info on it. thanks Edited June 6, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Zibit Posted June 6, 2010 Share Posted June 6, 2010 im not sure you can change the color of an inputbox... though im gonna look into it Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Zibit Posted June 6, 2010 Share Posted June 6, 2010 wait... using switch you have to push a button... Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Zibit Posted June 6, 2010 Share Posted June 6, 2010 #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input2 EndSwitch WEnd works... Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
Tiboi Posted June 6, 2010 Author Share Posted June 6, 2010 im not sure you can change the color of an inputbox... though im gonna look into it it can be changed, but i want it to change while i am typing. even this dont work: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input2 $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) While $Input1txt <> $Input2txt GUICtrlSetBkColor($Input2, 0x00ff00) ExitLoop $Input1txt = $Input2txt GUICtrlSetBkColor($Input2, 0xFF0000) WEnd EndSwitch WEnd Link to comment Share on other sites More sharing options...
Tiboi Posted June 6, 2010 Author Share Posted June 6, 2010 #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input2 EndSwitch WEnd works... sweet thank you very much:) Link to comment Share on other sites More sharing options...
Tiboi Posted June 6, 2010 Author Share Posted June 6, 2010 how would you put it in its own function and then call itunder case $input2? Link to comment Share on other sites More sharing options...
Yoriz Posted June 6, 2010 Share Posted June 6, 2010 Your original script was fine, but i needed to recieve a change made in the $input2 followed by pressing enter to trigger the 'Case $Input2' The following example uses 'GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")' and inside Func WM_COMMAND it uses '$EN_CHANGE' to trigger the recolouring on change of the input data. Ive made it so that it checks if theres a match in the second if either of the input's data is changed. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hInput2, $hInput1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Tiboi Posted June 6, 2010 Author Share Posted June 6, 2010 Your original script was fine, but i needed to recieve a change made in the $input2 followed by pressing enter to trigger the 'Case $Input2' The following example uses 'GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")' and inside Func WM_COMMAND it uses '$EN_CHANGE' to trigger the recolouring on change of the input data. Ive made it so that it checks if theres a match in the second if either of the input's data is changed. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hInput2, $hInput1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND thanks for the help. you are on a whole new lvl of scripting. this code has stuff i've never seen lol Link to comment Share on other sites More sharing options...
Tiboi Posted June 6, 2010 Author Share Posted June 6, 2010 i cant fully understand your script yet yoriz but i will be using it. can you add $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 240, 96, 97, 17)to it for me please. and edit the script to only happen it the checkbox is checked. thanks for the help Link to comment Share on other sites More sharing options...
JohnOne Posted June 6, 2010 Share Posted June 6, 2010 i cant fully understand your script yet yoriz but i will be using it. can you add $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 240, 96, 97, 17)to it for me please. and edit the script to only happen it the checkbox is checked. thanks for the help In all honesty that is a really simple task that, given your first script you ought to be able to do. I'm not having a go but if you learn you wont have to ask little things like this. You will wind up having to send him a toilet tissue roll so he can give you a little wipe when he's finished your script. 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...
Yoriz Posted June 6, 2010 Share Posted June 6, 2010 I've changed it so there is a function you can alter without having to understand the 'Func WM_COMMAND'. Func _Inputs1Or2Changed() is triggered when either input is altered so you can now alter this function as you wish. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 240, 96, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 _Inputs1Or2Changed() EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hInput2, $hInput1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control _Inputs1Or2Changed() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Inputs1Or2Changed() If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf Else GUICtrlSetBkColor($Input2, 0xFFFFFF) EndIf EndFunc ;==>_Inputs1n2Changed GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Tiboi Posted June 7, 2010 Author Share Posted June 7, 2010 (edited) I've changed it so there is a function you can alter without having to understand the 'Func WM_COMMAND'. Func _Inputs1Or2Changed() is triggered when either input is altered so you can now alter this function as you wish. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; used for Lo/Hi word #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 623, 442, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 224, 168, 121, 21) $Input2 = GUICtrlCreateInput("Input2", 224, 208, 121, 21) $hInput1 = GUICtrlGetHandle($Input1) $hInput2 = GUICtrlGetHandle($Input2) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 240, 96, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 _Inputs1Or2Changed() EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $hInput2, $hInput1 Switch $iCode Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control _Inputs1Or2Changed() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Inputs1Or2Changed() If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then $Input1txt = GUICtrlRead($Input1) $Input2txt = GUICtrlRead($Input2) If $Input1txt = $Input2txt Then GUICtrlSetBkColor($Input2, 0x00ff00) Else GUICtrlSetBkColor($Input2, 0xFF0000) EndIf Else GUICtrlSetBkColor($Input2, 0xFFFFFF) EndIf EndFunc ;==>_Inputs1n2Changed thank you very much for the help man. i appreciate it can you direct me to somewhere that i can learn this. the autoit help file isn't very helpful on this. cause i will want to use this to also check if data i type in an input box is the same as what is saved in an ini file. i want to learn it for myself instead of asking questions all the time so that i would not be talked down to from people like the previous know it all guy. Edited June 7, 2010 by Tiboi 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