Jump to content

checkbox function .... please

Recommended Posts

hello everybody

I use this script to make GUI readme for just once

and this is :

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)


Func _Main()
    Local $gobutton, $state, $msg, $Chekbox
    Local $pic
    #forceref $separator1

    GUICreate("Readme", 600, 400)

    $gobutton = GUICtrlCreateButton("GO", 265, 350, 100, 25)
    $pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,300)
    $Chekbox = GuiCtrlCreateCheckbox("Don't show this message again", 25, 370, 200, 20)
    $state = GuiCtrlSetState(-1, $GUI_UNCHECKED)
    While 1
        $msg = GUIGetMsg()

            Case $msg = $GUI_EVENT_CLOSE 
                MsgBox(0, "Click", "good bye")
            Case $msg = $gobutton
                MsgBox(0, "Click", "You clicked OK!")


I suggest when the box is checked write text file somewhere and next time check that file then won't show this again

and I used in Func _Main() for checkbox :

when it's checked ---- > write a text file

when it's unchecked ---- > delete that file

like this

Func _Main()
    While 1

            Case $state =  GuiCtrlSetState(1, $GUI_CHECKED) 
                FileWrite ("File.txt","Text")
            Case $state =  GuiCtrlSetState(-1, $GUI_UNCHECKED)

but it didn't work

please help me

Edited by AlienStar
Link to comment
Share on other sites

  • Moderators


Using -1 in commands like $state = GuiCtrlSetState(-1, $GUI_UNCHECKED) is shorthand for "the control just created". So when you come to your loop and use Case $state = GuiCtrlSetState(1, $GUI_CHECKED) AutoIt has probably forgotten what that was!

You also need to look at the current state of the checkbox - not compare it with what it was. Try using this:

Case GUICtrlRead($Chekbox) = 1 ; This is checked

Case GUICtrlRead($ChekBox) = 4 ; This is unchecked


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Link to comment
Share on other sites

thanks Thanubis but I found that's not enough

because nothing happen after putting this

$pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,400)

so I looked for that in help and found


after using this

$pic = GuiCtrlCreatePic("pic.jpg",0,0, 600,400)

everything becomes well

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

  • Recently Browsing   0 members

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