Monty Posted January 31, 2010 Share Posted January 31, 2010 Can someone help me with this one please? ** SEE EXAMPLE ** 1. When the checkbox is not checked, I can modify text in the inputbox...all good! 2. When I check the checkbox, inputbox is set with dafault data "Test message!"...all good! Now question: is there a way to modify this script so that I can change the inputbox data from "Test message!" to anything else without unchecking the checkbox. YOUR HELP WILL BE APPRECIATED. THANK YOU. Monty. #include <GUIConstantsEx.au3> $guimain = GUICreate("Test", 300, 145) $testcbox = GUICtrlCreateCheckbox("Test Checkbox", 30, 32, 97, 17) $testinput = GUICtrlCreateInput("", 30, 64, 121, 21) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Case GUICtrlRead($testcbox) = $GUI_CHECKED GUICtrlSetData($testinput, "Test message!") EndSelect Until Not WinExists($guimain) Link to comment Share on other sites More sharing options...
NerdFencer Posted January 31, 2010 Share Posted January 31, 2010 Your problem is that the script is continually updating the test in the input box to the test text. You need to make it only set the text once after the checkbox is checked. See the modified script below. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $guimain = GUICreate("Test", 300, 145) $testcbox = GUICtrlCreateCheckbox("Test Checkbox", 30, 32, 97, 17) $testinput = GUICtrlCreateInput("", 30, 64, 121, 21) GUISetState(@SW_SHOW) $unchecked = True Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Case GUICtrlRead($testcbox) == $GUI_CHECKED And $unchecked==True GUICtrlSetData($testinput, "Test message!") $unchecked = False Case GUICtrlRead($testcbox) == $GUI_UNCHECKED $unchecked = True EndSelect Sleep(15) Until Not WinExists($guimain) _________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell Link to comment Share on other sites More sharing options...
Zedna Posted January 31, 2010 Share Posted January 31, 2010 (edited) Simpler way: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $guimain = GUICreate("Test", 300, 145) $testcbox = GUICtrlCreateCheckbox("Test Checkbox", 30, 32, 97, 17) $testinput = GUICtrlCreateInput("", 30, 64, 121, 21) GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete() Case $msg = $testcbox If GUICtrlRead($testcbox) = $GUI_CHECKED Then GUICtrlSetData($testinput, "Test message!") EndSelect Until Not WinExists($guimain) Edited January 31, 2010 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Monty Posted February 1, 2010 Author Share Posted February 1, 2010 Thank you for both examples. Has definately solved my issues. 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