Sign in to follow this  
Followers 0
risen75

Help with Checkboxes

6 posts in this topic

OK i know this question has probably been answered about a million times already (and i've found a few of them that didn't quite get me where i need to be) but I'm having trouble with multiple checkboxes. Now I'm just trying to make a GUI frontend to an installation script for me and my friends. Worked fine w/o the gui, but I want to make it so that they can pick and choose which of the programs they want to instal.

Now the problems I'm having are this....

After showing the GUI i can check off the checkboxes, but when I'd go and hit the install button i'd get wierd errors (sorry i don't have them to post, i've rewritten the script so many times trying to debug it that i don't remember how it originally was) Now i've had the AhAA moment with reading the checkboxes...

But now when i run the script it just flashes up on the screen and then disappears...

Here's the current code... Please Help! Tell me what i'm doing wrong :)

Thank you in advance for the help.

Code:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=F:\setups\Installergui.kxf

$Form1 = GUICreate("Auto Installer", 252, 238, 332, 154)

$Checkbox1 = GUICtrlCreateCheckbox("Open Office", 24, 24, 105, 17)

$Checkbox2 = GUICtrlCreateCheckbox("mIRC", 24, 40, 105, 17)

$Checkbox3 = GUICtrlCreateCheckbox("FireFox", 24, 56, 105, 17)

$Checkbox4 = GUICtrlCreateCheckbox("DivX", 24, 72, 105, 17)

$Checkbox5 = GUICtrlCreateCheckbox("XVid", 24, 88, 105, 17)

$Checkbox6 = GUICtrlCreateCheckbox("Yahoo Messenger", 24, 104, 105, 17)

$Checkbox7 = GUICtrlCreateCheckbox("Deamon Tools", 24, 120, 105, 17)

$Progress1 = GUICtrlCreateProgress(24, 144, 193, 25)

$Checkbox8 = GUICtrlCreateCheckbox("DreamWeaver", 136, 24, 105, 17)

$Checkbox9 = GUICtrlCreateCheckbox("Filezilla", 136, 40, 105, 17)

$Checkbox10 = GUICtrlCreateCheckbox("Utorrent", 136, 56, 105, 17)

$Label1 = GUICtrlCreateLabel("What programs do you wish to install?", 24, 8, 182, 17)

$Checkbox11 = GUICtrlCreateCheckbox("GIMP", 136, 72, 105, 17)

$Button1 = GUICtrlCreateButton("Install", 24, 184, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Exit", 112, 184, 65, 25, 0)

GUICtrlSetOnEvent($Button1, "Install")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Func Install()

If GUICtrlRead($CheckBox1)=$GUI_CHECKED Then

RunWait("openoffice.exe")

EndIf

If GUICtrlRead($CheckBox2)=$GUI_CHECKED Then

RunWait("mirc.exe")

EndIf

If GUICtrlRead($CheckBox3)=$GUI_CHECKED Then

RunWait("Firefox.exe")

EndIf

If GUICtrlRead($CheckBox4)=$GUI_CHECKED Then

RunWait("divx.exe")

EndIf

If GUICtrlRead($CheckBox5)=$GUI_CHECKED Then

RunWait("xvid.exe")

EndIf

If GUICtrlRead($CheckBox6)=$GUI_CHECKED Then

RunWait("yahoo.exe")

EndIf

If GUICtrlRead($CheckBox7)=$GUI_CHECKED Then

RunWait("deamon.exe")

EndIf

If GUICtrlRead($CheckBox8)=$GUI_CHECKED Then

RunWait("dreamweaver.exe")

EndIf

If GUICtrlRead($CheckBox9)=$GUI_CHECKED Then

RunWait("filezilla.exe")

EndIf

If GUICtrlRead($CheckBox10)=$GUI_CHECKED Then

RunWait("utorrent.exe")

EndIf

If GUICtrlRead($CheckBox11)=$GUI_CHECKED Then

RunWait("gimp.exe")

EndIf

EndFunc

Share this post


Link to post
Share on other sites



OK i know this question has probably been answered about a million times already (and i've found a few of them that didn't quite get me where i need to be) but I'm having trouble with multiple checkboxes. Now I'm just trying to make a GUI frontend to an installation script for me and my friends. Worked fine w/o the gui, but I want to make it so that they can pick and choose which of the programs they want to instal.

Now the problems I'm having are this....

After showing the GUI i can check off the checkboxes, but when I'd go and hit the install button i'd get wierd errors (sorry i don't have them to post, i've rewritten the script so many times trying to debug it that i don't remember how it originally was) Now i've had the AhAA moment with reading the checkboxes...

But now when i run the script it just flashes up on the screen and then disappears...

Here's the current code... Please Help! Tell me what i'm doing wrong :)

Thank you in advance for the help.

Code:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=F:\setups\Installergui.kxf

$Form1 = GUICreate("Auto Installer", 252, 238, 332, 154)

$Checkbox1 = GUICtrlCreateCheckbox("Open Office", 24, 24, 105, 17)

$Checkbox2 = GUICtrlCreateCheckbox("mIRC", 24, 40, 105, 17)

$Checkbox3 = GUICtrlCreateCheckbox("FireFox", 24, 56, 105, 17)

$Checkbox4 = GUICtrlCreateCheckbox("DivX", 24, 72, 105, 17)

$Checkbox5 = GUICtrlCreateCheckbox("XVid", 24, 88, 105, 17)

$Checkbox6 = GUICtrlCreateCheckbox("Yahoo Messenger", 24, 104, 105, 17)

$Checkbox7 = GUICtrlCreateCheckbox("Deamon Tools", 24, 120, 105, 17)

$Progress1 = GUICtrlCreateProgress(24, 144, 193, 25)

$Checkbox8 = GUICtrlCreateCheckbox("DreamWeaver", 136, 24, 105, 17)

$Checkbox9 = GUICtrlCreateCheckbox("Filezilla", 136, 40, 105, 17)

$Checkbox10 = GUICtrlCreateCheckbox("Utorrent", 136, 56, 105, 17)

$Label1 = GUICtrlCreateLabel("What programs do you wish to install?", 24, 8, 182, 17)

$Checkbox11 = GUICtrlCreateCheckbox("GIMP", 136, 72, 105, 17)

$Button1 = GUICtrlCreateButton("Install", 24, 184, 75, 25, 0)

$Button2 = GUICtrlCreateButton("Exit", 112, 184, 65, 25, 0)

GUICtrlSetOnEvent($Button1, "Install")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Func Install()

If GUICtrlRead($CheckBox1)=$GUI_CHECKED Then

RunWait("openoffice.exe")

EndIf

If GUICtrlRead($CheckBox2)=$GUI_CHECKED Then

RunWait("mirc.exe")

EndIf

If GUICtrlRead($CheckBox3)=$GUI_CHECKED Then

RunWait("Firefox.exe")

EndIf

If GUICtrlRead($CheckBox4)=$GUI_CHECKED Then

RunWait("divx.exe")

EndIf

If GUICtrlRead($CheckBox5)=$GUI_CHECKED Then

RunWait("xvid.exe")

EndIf

If GUICtrlRead($CheckBox6)=$GUI_CHECKED Then

RunWait("yahoo.exe")

EndIf

If GUICtrlRead($CheckBox7)=$GUI_CHECKED Then

RunWait("deamon.exe")

EndIf

If GUICtrlRead($CheckBox8)=$GUI_CHECKED Then

RunWait("dreamweaver.exe")

EndIf

If GUICtrlRead($CheckBox9)=$GUI_CHECKED Then

RunWait("filezilla.exe")

EndIf

If GUICtrlRead($CheckBox10)=$GUI_CHECKED Then

RunWait("utorrent.exe")

EndIf

If GUICtrlRead($CheckBox11)=$GUI_CHECKED Then

RunWait("gimp.exe")

EndIf

EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

risen75

You forgot to set the loop :)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=F:\setups\Installergui.kxf
$Form1 = GUICreate("Auto Installer", 252, 238, 332, 154)
$Checkbox1 = GUICtrlCreateCheckbox("Open Office", 24, 24, 105, 17)
$Checkbox2 = GUICtrlCreateCheckbox("mIRC", 24, 40, 105, 17)
$Checkbox3 = GUICtrlCreateCheckbox("FireFox", 24, 56, 105, 17)
$Checkbox4 = GUICtrlCreateCheckbox("DivX", 24, 72, 105, 17)
$Checkbox5 = GUICtrlCreateCheckbox("XVid", 24, 88, 105, 17)
$Checkbox6 = GUICtrlCreateCheckbox("Yahoo Messenger", 24, 104, 105, 17)
$Checkbox7 = GUICtrlCreateCheckbox("Deamon Tools", 24, 120, 105, 17)
$Progress1 = GUICtrlCreateProgress(24, 144, 193, 25)
$Checkbox8 = GUICtrlCreateCheckbox("DreamWeaver", 136, 24, 105, 17)
$Checkbox9 = GUICtrlCreateCheckbox("Filezilla", 136, 40, 105, 17)
$Checkbox10 = GUICtrlCreateCheckbox("Utorrent", 136, 56, 105, 17)
$Label1 = GUICtrlCreateLabel("What programs do you wish to install?", 24, 8, 182, 17)
$Checkbox11 = GUICtrlCreateCheckbox("GIMP", 136, 72, 105, 17)
$Button1 = GUICtrlCreateButton("Install", 24, 184, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Exit", 112, 184, 65, 25, 0)
GUICtrlSetOnEvent($Button1, "Install")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Main loop :)
While 1
    Sleep(100)
WEnd

Func Install()
If GUICtrlRead($CheckBox1)=$GUI_CHECKED Then 
RunWait("openoffice.exe")
EndIf
If GUICtrlRead($CheckBox2)=$GUI_CHECKED Then 
RunWait("mirc.exe")
EndIf
If GUICtrlRead($CheckBox3)=$GUI_CHECKED Then 
RunWait("Firefox.exe")
EndIf
If GUICtrlRead($CheckBox4)=$GUI_CHECKED Then 
RunWait("divx.exe")
EndIf
If GUICtrlRead($CheckBox5)=$GUI_CHECKED Then 
RunWait("xvid.exe")
EndIf
If GUICtrlRead($CheckBox6)=$GUI_CHECKED Then 
RunWait("yahoo.exe")
EndIf
If GUICtrlRead($CheckBox7)=$GUI_CHECKED Then
RunWait("deamon.exe")
EndIf
If GUICtrlRead($CheckBox8)=$GUI_CHECKED Then 
RunWait("dreamweaver.exe")
EndIf
If GUICtrlRead($CheckBox9)=$GUI_CHECKED Then 
RunWait("filezilla.exe")
EndIf
If GUICtrlRead($CheckBox10)=$GUI_CHECKED Then 
RunWait("utorrent.exe")
EndIf
If GUICtrlRead($CheckBox11)=$GUI_CHECKED Then 
RunWait("gimp.exe")
EndIf
EndFunc
Edited by rasim

Share this post


Link to post
Share on other sites

and perhaps a way to close EXIT?

Share this post


Link to post
Share on other sites

I know, I forgot to make it so that you can close it.. I was more worried about the rest of it working right... closing it is easy :)

But thank you guys for your help.. Tested it out (with adding the ability to close the program) and it's working fine.. now i just have to finish making all the other scripts for the programs (yes i like having it call other scripts, it just seems more organized to me that way)

Share this post


Link to post
Share on other sites

What actually is the problem is that the program starts, then processes the commands that it has to do (create the gui). Then it goes on with the next command, when all commands are processed, the program will exit, just as you described.

What you want to achieve is that the program waits to find which function should be called, so after the creation of the gui, you should add something like:

While 1
  Sleep(100)
WEndoÝ÷ Ù8^¢w¯z{f¡×°Yj붩®+jkh­æ¶ÚëÞا¶ º,¨¹ÊÞj×jwZ~éܶ*'Â)eiËnjYrmçWº{bØ^~éܶ*'ªê-{­ªê-ÇW"jezg§µçb*.­Êy«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì()=ÁÐ ÅÕ½ÐíU%=¹Ù¹Ñ5½ÅÕ½Ðì°Ä¤(I¥½¸MQIP-½U$ÍÑ¥½¸½É´õèÀäÈíÍÑÕÁÌÀäÈí%¹Íѱ±ÉÕ¤¹­á(ÀÌØí½É´ÄôU%
ÉÑ ÅÕ½ÐíÕѼ%¹Íѱ±ÈÅÕ½Ðì°ÈÔÈ°ÈÌà°ÌÌÈ°ÄÔФ(ÀÌØí
¡­½àÄôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðí=Á¸=¥ÅÕ½Ðì°ÈаÈаÄÀÔ°Äܤ(ÀÌØí
¡­½àÈôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíµ%IÅÕ½Ðì°ÈаÐÀ°ÄÀÔ°Äܤ(ÀÌØí
¡­½àÌôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðí¥É½àÅÕ½Ðì°ÈаÔØ°ÄÀÔ°Äܤ(ÀÌØí
¡­½àÐôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðí¥Ù`ÅÕ½Ðì°ÈаÜÈ°ÄÀÔ°Äܤ(ÀÌØí
¡­½àÔôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½ÐíaY¥ÅÕ½Ðì°Èаàà°ÄÀÔ°Äܤ(ÀÌØí
¡­½àØôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíe¡½¼5Í͹ÈÅÕ½Ðì°ÈаÄÀаÄÀÔ°Äܤ(ÀÌØí
¡­½àÜôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíµ½¸Q½½±ÌÅÕ½Ðì°ÈаÄÈÀ°ÄÀÔ°Äܤ(ÀÌØíAɽÉÍÌÄôU%
Ñɱ
ÉÑAɽÉÍÌ ÈаÄÐаÄäÌ°ÈÔ¤(ÀÌØí
¡­½ààôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðíɵ]ÙÈÅÕ½Ðì°ÄÌØ°ÈаÄÀÔ°Äܤ(ÀÌØí
¡­½àäôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðí¥±é¥±±ÅÕ½Ðì°ÄÌØ°ÐÀ°ÄÀÔ°Äܤ(ÀÌØí
¡­½àÄÀôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½ÐíUѽÉɹÐÅÕ½Ðì°ÄÌØ°ÔØ°ÄÀÔ°Äܤ(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½Ðí]¡ÐÁɽɵ̼å½ÔÝ¥Í Ñ¼¥¹Íѱ°üÅÕ½Ðì°Èаà°ÄàÈ°Äܤ(ÀÌØí
¡­½àÄÄôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½Ðí%5@ÅÕ½Ðì°ÄÌØ°ÜÈ°ÄÀÔ°Äܤ(ÀÌØí ÕÑѽ¸ÄôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðí%¹Íѱ°ÅÕ½Ðì°ÈаÄàаÜÔ°ÈÔ°À¤(ÀÌØí ÕÑѽ¸ÈôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½Ðíá¥ÐÅÕ½Ðì°ÄÄÈ°ÄàаØÔ°ÈÔ°À¤)U%
ÑɱMÑ=¹Ù¹Ð ÀÌØí ÕÑѽ¸Ä°ÅÕ½Ðí%¹Íѱ°ÅÕ½Ðì¤)U%MÑMÑÑ¡M]}M!=¤(¹I¥½¸9-½U$ÍÑ¥½¸()]¡¥±Ä(M±À ÄÀÀ¤)]¹()Õ¹%¹Íѱ° ¤)%U%
ÑɱI ÀÌØí
¡­    ½àĤôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí½Á¹½¥¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àȤôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðíµ¥É¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½à̤ôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí¥É½à¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àФôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí¥Ùà¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àÔ¤ôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½ÐíáÙ¥¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àؤôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí塽¼¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àܤôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðíµ½¸¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àà¤ôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½ÐíɵÝÙȹáÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àä¤ôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí¥±é¥±±¹áÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àÄÀ¤ôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½ÐíÕѽÉɹйáÅÕ½Ðì¤)¹%)%U%
ÑɱI ÀÌØí
¡­    ½àÄĤôÀÌØíU%}
!
-Q¡¸)IÕ¹]¥Ð ÅÕ½Ðí¥µÀ¹áÅÕ½Ðì¤)¹%)¹Õ¹

In the beginning there was nothing and then even that exploded - anonymous

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