Jump to content

help with $GUI_Checked


Recommended Posts

I am trying to run a function if a check box is checked and and button is pressed cant get it to work. I tried reading the GUICtrlSetState and GUICtrlGetState but am not understanding it.

Here is what I had/have that aint workin

$Button1 = GUICtrlCreateButton("Test button", 224, 16, 137, 33, 0)
GUICtrlSetTip(-1, "this is a test button")
GUICtrlSetOnEvent(-1,"FileSetup")

$CheckBox1 = GUICtrlCreateCheckbox("This is a test checkbox", 16, 56, 137, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "this is a hint for this check box")

Func FileSetup()
    GUISetState(@SW_HIDE)
    If $CheckBox1 = $GUI_CHECKED Then
        MsgBox(1024,"This is a test","This is a test")
    EndIf
EndFunc

Thanks,

MrChris

Link to comment
Share on other sites

Did you check the Gui Forum 1st? :whistle: as this is GUI stuff.

Use GUICtrlRead on the control handle.

$Button1 = GUICtrlCreateButton("Test button", 224, 16, 137, 33, 0)
GUICtrlSetTip(-1, "this is a test button")
GUICtrlSetOnEvent(-1,"FileSetup")

$CheckBox1 = GUICtrlCreateCheckbox("This is a test checkbox", 16, 56, 137, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "this is a hint for this check box")

Func FileSetup()
    GUISetState(@SW_HIDE)
    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
        MsgBox(1024,"This is a test","This is a test")
    EndIf
EndFunc

:)

Link to comment
Share on other sites

  • Moderators

#include <GUICONSTANTS.AU3>
Opt('GUIONEVENTMODE', 1)

$MAIN = GUICreate('SOMETITLE', 500, 300)
$Button1 = GUICtrlCreateButton("Test button", 224, 16, 137, 33, 0)
GUICtrlSetTip(-1, "this is a test button")
GUICtrlSetOnEvent(-1,"FileSetup")

$CheckBox1 = GUICtrlCreateCheckbox("This is a test checkbox", 16, 56, 137, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, "this is a hint for this check box")
GUISetState()

While 1
    Sleep(10000)
WEnd

Func FileSetup()
    GUISetState(@SW_HIDE)
    If BitAND(GUICtrlRead($CheckBox1), $GUI_CHECKED) = $GUI_CHECKED Then
        MsgBox(1024,"This is a test","This is a test")
    EndIf
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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