Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Disable button if input is empty and checkbox unchecked

$
0
0

Hallo forum members,

 

Question?

checkbox1 checked, input filled in, then  Button1 active.

I think this question is ask many times but the search results brings me further away.

First start script works good, "Button1" is disabled, when input box is filled in "Button1" is still disabled, when $Checkbox1 is checked "Button1" is enabled so far so good.
But when I uncheck $Checkbox1 "Button1" is still active!
 

The script, forgot to tell that the script have to start up with $Checkbox1 checked.

AutoIt         
#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #region ### START Koda GUI section ### $Form1 = GUICreate("Form1", 401, 193, 192, 124) $Input1 = GUICtrlCreateInput("", 120, 16, 160, 21) $Button1 = GUICtrlCreateButton("Button1", 120, 72, 160, 25) GUICtrlSetState($Button1, $GUI_DISABLE) $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 122, 128, 97, 17) GUICtrlSetState($Checkbox1, $GUI_CheckED) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### $i = 1 While 1     If BitAnd(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) = $GUI_UNCHECKED And GUICtrlRead($Input1) = ""  And $i = 1 Then         GUICtrlSetState($Button1, $GUI_DISABLE)         $i = 0         MsgBox(0, "Unchecked", "Test unchecked", 10)     Else         If $i = 0 And BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED) = $GUI_CHECKED And GUICtrlRead($Input1) <> "" Then             GUICtrlSetState($Button1, $GUI_ENABLE)             $i = 1             MsgBox(0, "Checked", "Test checked", 10)         EndIf     EndIf     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $Button1             ; do your thing     EndSwitch WEnd

 

Part of the source Calling a result from GUICtrlCreateCheckbox

 

Thanks in advance.

 

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>