Sign in to follow this  
Followers 0
CGAnimator

Checkbox Program

4 posts in this topic

Hi,

I used autoit for a while and it's really wonderful but it's the 1st time to me to use it's GUI Method

what i wanted to do is a little program that have some nice checkboxes :whistle:

and the user select the options he want then press excute button.

when he do, the program excutes some files "mostly *.reg and *.bat files". for every option.

i mean if the user checked checkbox 1,2 and 4 the program excutes the files 1,2 and 4 .

so i made the GUI and so on, but i get stuck at the rest

here is the script untill now

thanx in advance

#include <GUIConstants.au3>

OPT ("TrayIconHide",1)

GUICreate("Fajr4 Menu",400,400,310,190,$WS_POPUPWINDOW)

GUISetIcon (@ScriptDir & "\Fajr.ico",-1)

GUICtrlCreateLabel("Please Select the Option you want to Execute", 77, 30)

GUICtrlCreateCheckbox("Option 1",10,90)

GUICtrlCreateCheckbox("Option 2",10,110)

GUICtrlCreateCheckbox("Option 3",10,130)

GUICtrlCreateCheckbox("Option 4",10,150)

GUICtrlCreateCheckbox("Option 5",10,170)

GUICtrlCreateCheckbox("Option 6",10,190)

GUICtrlCreateCheckbox("Option 7",10,210)

GUICtrlCreateCheckbox("Option 8",10,230)

$exit = GUICtrlCreateButton("Exit", 320, 330, 60)

$Option = GUICtrlCreateButton("Excute",10,300,60)

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $exit

ExitLoop

EndSelect

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm still kind of new to Autoit, but this works. Maybe there's a better way, though.

#include <GUIConstants.au3>
Opt("TrayIconHide", 1)
GUICreate("Fajr4 Menu", 400, 400, 310, 190, $WS_POPUPWINDOW)
GUISetIcon(@ScriptDir & "\Fajr.ico", -1)
GUICtrlCreateLabel("Please Select the Option you want to Execute", 77, 30)
$opt1 = GUICtrlCreateCheckbox("Option 1", 10, 90)
$opt2 = GUICtrlCreateCheckbox("Option 2", 10, 110)
$opt3 = GUICtrlCreateCheckbox("Option 3", 10, 130)
$opt4 = GUICtrlCreateCheckbox("Option 4", 10, 150)
$opt5 = GUICtrlCreateCheckbox("Option 5", 10, 170)
$opt6 = GUICtrlCreateCheckbox("Option 6", 10, 190)
$opt7 = GUICtrlCreateCheckbox("Option 7", 10, 210)
$opt8 = GUICtrlCreateCheckbox("Option 8", 10, 230)
$exit = GUICtrlCreateButton("Exit", 320, 330, 60)
$Option = GUICtrlCreateButton("Excute", 10, 300, 60)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $exit
            Exit
        Case $msg = $Option
            If GUICtrlRead($opt1) = 1 Then
                MsgBox(0, "", "opt 1 is checked")
            EndIf
            If GUICtrlRead($opt2) = 1 Then
                MsgBox(0, "", "opt 2 is checked")
            EndIf
            If GUICtrlRead($opt3) = 1 Then
                MsgBox(0, "", "opt 3 is checked")
            EndIf
            If GUICtrlRead($opt4) = 1 Then
                MsgBox(0, "", "opt 4 is checked")
            EndIf
            If GUICtrlRead($opt5) = 1 Then
                MsgBox(0, "", "opt 5 is checked")
            EndIf
            If GUICtrlRead($opt6) = 1 Then
                MsgBox(0, "", "opt 6 is checked")
            EndIf
            If GUICtrlRead($opt7) = 1 Then
                MsgBox(0, "", "opt 7 is checked")
            EndIf
            If GUICtrlRead($opt8) = 1 Then
                MsgBox(0, "", "opt 8 is checked")
            EndIf
    EndSelect
WEnd
Edited by xcal

Share this post


Link to post
Share on other sites

Or this looks better for the loop:

Dim $opts[9] = [8, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8]
Dim $files[9] = [8, "file1.bat", "file2.bat", "file3.bat", "file4.bat", "file5.bat", "file6.bat", "file7.bat", "file8.bat"]

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $exit
            Exit
        Case $msg = $Option
            For $i = 1 To 8
                If GUICtrlRead($opts[$i]) = 1 Then
                    MsgBox(0, "", "Option " & $i & " is checked.  Executing " & $files[$i])
                EndIf
            Next
    EndSelect
WEnd

Like I said, I'm still new to autoit, so there may be a better way... dunno.

Share this post


Link to post
Share on other sites

Thanx man .... sooooo much

you made my day :whistle:

i really tried every thing but it didnt' work

i did the same as you described, but i must did some stupid mistake.

the program now works very will.

the 2nd solution gives me a number of errors it didnt' work with me

but the 1st works like magic :) .

thanx again.

Share this post


Link to post
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
Sign in to follow this  
Followers 0