Jump to content

Work with checkbox


daniel02
 Share

Recommended Posts

Hi all,

I tired now for several minutes work with a checkbox but I can get it run. Also the help file did not help me :o

For you guys it will be very easy I think. :D

If the checkbox is "checked" I want to set a variable to 1. If it is not checked to 0. As log as the script is running I want to be able to change the state of this variable with the checkbox.

The only thing I found is $GUI_UNCHECKED $GUI_CHECKED but I am not sure how to work with it.

Thanks in advance

Daniel

Link to comment
Share on other sites

Search the help file for '_GUICtrlButton_GetCheck', there is an example script using radio buttons and a check box

I tired now for several minutes work with a checkbox but I can get it run. Also the help file did not help me :D

Link to comment
Share on other sites

  • Developers

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)
Global $checkCN, $msg, $Checked = 0
GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

$checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20)

GUISetState()     ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
        Case $msg = $checkCN
            If GUICtrlRead($checkCN) = $GUI_CHECKED Then
                $Checked = 1
            Else
                $Checked = 0
            EndIf
    EndSelect
WEnd

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $checkCN, $msg
    GUICreate("My GUI Checkbox")  ; will create a dialog box that when displayed is centered

    $checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20)
    GUICtrlSetState(-1, $GUI_CHECKED)   ; the checkbox is checked

    GUISetState()       ; will display an  dialog box with 1 checkbox

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

I just wantED to set the debug mode on or off with the checkbox.. And it is working now :D

Thanks a lot!!!!

Here is my code perhaps there is a better way?

GuiCreate($Prog_Title, 200, 250)

WinSetOnTop($Prog_Title, "", 1)

$start = GUICtrlCreateButton(" Start ",10, 10)

$stop = GUICtrlCreateButton(" Stop ", 80, 10)

$debugon = GUICtrlCreateCheckbox ("Debug Mode", 5, 130)

GUICtrlCreateLabel("Current Function/Debug:", 5, 150)

$CurrentFunction = GUICtrlCreateInput("Function", 5, 170, 125, 20)

GuiSetState()

While 1

If ControlCommand ( $Prog_Title, "", $debugon, "IsChecked") = 1

$debug=1

Else

$debug=0

endif

$msg = GUIGetMsg()

Select

Case $msg = $start

;CorrectHeadingNew($zieloxpos, $zieloypos)

heading()

Case $msg = $stop

Exit

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

WEnd

Func heading()

If $debug = 1 Then GUICtrlSetData($CurrentFunction, " Heading ")

$d1=abs($headpos - $zipos)

If abs($headpos - $zielheadpos) < 180 Then

MsgBox(0, "Heading", "right" &$d1)

Else

MsgBox(0, "Heading", "left"&$d1)

EndIf

EndFunc ; ######## heading

Link to comment
Share on other sites

...perhaps there is a better way?

Maybe not better per se, but shorter....

replace:

If ControlCommand($Prog_Title, "", $debugon, "IsChecked") = 1 Then
        $debug = 1
    Else
        $debug = 0
    EndIf

with this:

$debug = 0
    If GUICtrlRead($debugon) = 1 Then $debug = 1
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
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...