Jump to content

createcheckbox


pensfan
 Share

Recommended Posts

I am new to writing scripts using the GUI, what i need to do is create a small window with 7 or 8 checkboxs or radio buttons, with 1 button, depending what what boxes are checked in the menu the button will run a command for each one that is checked. I have looked and can't find any sample scripts, if someone could point me in the general direction of something similar, it would greatly help me out.

Link to comment
Share on other sites

I am new to writing scripts using the GUI, what i need to do is create a small window with 7 or 8 checkboxs or radio buttons, with 1 button, depending what what boxes are checked in the menu the button will run a command for each one that is checked. I have looked and can't find any sample scripts, if someone could point me in the general direction of something similar, it would greatly help me out.

Welcome to the forums

at the bottom of each help file [age, there is a sample script showing the use

#include <GUIConstants.au3>

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()
    
     If $msg = $GUI_EVENT_CLOSE  Then ExitLoop
Wend

start with thiw and get the design you want...or

Use Scite Editor and press Tools > GUIBuilder or KODA Form Designer and you can create the GUI by a visual approach

after you get there we can help you get the button to read each control to see if it is checked

8)

NEWHeader1.png

Link to comment
Share on other sites

I am new to writing scripts using the GUI, what i need to do is create a small window with 7 or 8 checkboxs or radio buttons, with 1 button, depending what what boxes are checked in the menu the button will run a command for each one that is checked. I have looked and can't find any sample scripts, if someone could point me in the general direction of something similar, it would greatly help me out.

This is part of a code I use that I made a full blown app out of. This is the general principle I think you are asking about. Check this out and see if it helps you. If you run the code below it will be a sample of the how it works but just a really light version. You can add as many checkboxes as you want and make the apps as big as you need and even include tabs later on. Below is an image of my app but it has developed in to huge app but the main working if based on this principle below.

#include <GUIConstants.au3>

dim $Var1_CHKBOX
dim $Var2_CHKBOX
dim $RUN
dim $EXIT
dim $VarStatus1
dim $VarStatus2
Dim $GUINAME = "Installer Program"
GUICreate ($GUINAME,300,400)
GUISetFont(14,600)
GUICtrlCreateLabel($GUINAME,70,80)
GUISetFont(9,400)
$Var1_CHKBOX = GUICtrlCreateCheckbox("This is the first function to run",10,130)  ;Checkbox 1
$Var2_CHKBOX = GUICtrlCreateCheckbox("This is the second function to run",10,150)  ;Checkbox 2
$RUN = GUICtrlCreateButton("Run",10,350,120,20)  ;This is the Run button
$EXIT = GUICtrlCreateButton("Exit",168,350,120,20)  ;This is to exit the application
GUISetState()

Call ("Keep_Alive") ;This is the main function that keeps the program open even after you have ran one or more of the items.
                    ;Example, if you have 30 items you can run more items without having to restart the appliction.

Func Keep_Alive() 
Do
   $msg = GUIGetMsg()
;This checks the state of the Checkbox if it is checked or 1 then it will set the variable to that. 
$VarStatus1 = GUICtrlRead($Var1_CHKBOX)
$VarStatus2 = GUICtrlRead($Var2_CHKBOX)

Until $msg = $Run or $msg = $EXIT Or $msg = $GUI_EVENT_CLOSE

If $msg = $EXIT Then Exit
If $msg = $GUI_EVENT_CLOSE Then Exit
;If the status is 1 for the variable checkboxes when run is hit, it will execute those lines below which call the functions
If $VarStatus1 = 1 Then Call("ITEM_1")
If $VarStatus2 = 1 Then Call("ITEM_2")

Call ("Keep_Alive")
EndFunc


;This is where you would list your functions

Func ITEM_1()
 MsgBox(64, $GUINAME, "Whatever your 1st function is.", 10)
EndFunc

Func ITEM_2()
  MsgBox(64, $GUINAME, "Whatever your 2nd function is.", 10)
EndFunc

Posted Image

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

  • 1 month later...

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...