Sign in to follow this  
Followers 0
hanzz

Game / Trick

5 posts in this topic

Hey, I ask for your help again.

I have this great idea, but I'm stuck. I'm propably going about it the wrong way. I am an artist not a good programmer. Here's what I have now.

there's a few checkboxes that stand for a picture ,on which one has to check yes or no.

Al the NO's have "0" as value, the YES' have a different value.

So after checking all the checkboxes, I want the program to count them all together, giving me a value I can use to display another picture.

here's what I have(just the checkboxes, no pictures yet. )When the program is finished ,I will publish it here for all. It will be great fun ! -after seeing my site you know it will be fun !

CODE
#include <GUIConstants.au3>

$Form1_1 = GUICreate("Form1", 351, 148, 195, 117)

$Checkbox1 = GUICtrlCreateCheckbox("ja", 32, 16, 33, 17)

$Checkbox2 = GUICtrlCreateCheckbox("nee", 72, 16, 41, 17)

$Checkbox3 = GUICtrlCreateCheckbox("ja", 32, 56, 33, 17)

$Checkbox4 = GUICtrlCreateCheckbox("nee", 72, 56, 49, 17)

$Checkbox5 = GUICtrlCreateCheckbox("ja", 32, 96, 33, 17)

$Checkbox6 = GUICtrlCreateCheckbox("nee", 72, 96, 49, 17)

$Checkbox7 = GUICtrlCreateCheckbox("ja", 160, 16, 41, 17)

$Checkbox8 = GUICtrlCreateCheckbox("ja", 160, 56, 41, 17)

$Checkbox9 = GUICtrlCreateCheckbox("ja", 160, 96, 33, 17)

$Checkbox10 = GUICtrlCreateCheckbox("nee", 208, 16, 49, 17)

$Checkbox11 = GUICtrlCreateCheckbox("nee", 208, 56, 41, 17)

$Checkbox12 = GUICtrlCreateCheckbox("nee", 208, 96, 49, 17)

$Button1 = GUICtrlCreateButton("Button1", 272, 40, 49, 41, 0)

GUISetState(@SW_SHOW)

;values of each checkbox

GuiSetState()

$Checkbox1 = 1

$Checkbox2 = 0

$Checkbox3 = 2

$Checkbox4 = 0

$Checkbox5 = 4

$Checkbox6 = 0

$Checkbox7 = 8

$Checkbox8 = 0

$Checkbox9 = 16

$Checkbox10 = 0

$Checkbox11 = 32

$Checkbox12 = 0

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

BitAnd(GUICtrlRead($Checkbox1),$GUI_CHECKED)

BitAnd(GUICtrlRead($Checkbox2),$GUI_CHECKED)

BitAnd(GUICtrlRead($Checkbox3),$GUI_CHECKED)

BitAnd(GUICtrlRead($Checkbox4),$GUI_CHECKED)

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Share this post


Link to post
Share on other sites



You should be using radio buttons for Yes / No questions since only one choice is allowed. Using checkboxes the user can choose both Yes and No for a question.

Here is a cleaned up version of your code:

#include <GUIConstants.au3>

$Form1_1 = GUICreate("Form1", 351, 148, 195, 117)
$Checkbox1 = GUICtrlCreateCheckbox("ja", 32, 16, 33, 17)
$Checkbox2 = GUICtrlCreateCheckbox("nee", 72, 16, 41, 17)

$Checkbox3 = GUICtrlCreateCheckbox("ja", 32, 56, 33, 17)
$Checkbox4 = GUICtrlCreateCheckbox("nee", 72, 56, 49, 17)

$Checkbox5 = GUICtrlCreateCheckbox("ja", 32, 96, 33, 17)
$Checkbox6 = GUICtrlCreateCheckbox("nee", 72, 96, 49, 17)

$Checkbox7 = GUICtrlCreateCheckbox("ja", 160, 16, 41, 17)
$Checkbox8 = GUICtrlCreateCheckbox("nee", 208, 16, 49, 17)

$Checkbox9 = GUICtrlCreateCheckbox("ja", 160, 56, 41, 17)
$Checkbox10 = GUICtrlCreateCheckbox("nee", 208, 56, 41, 17)

$Checkbox11 = GUICtrlCreateCheckbox("ja", 160, 96, 33, 17)
$Checkbox12 = GUICtrlCreateCheckbox("nee", 208, 96, 49, 17)

$Button1 = GUICtrlCreateButton("Button1", 272, 40, 49, 41, 0)
GUISetState(@SW_SHOW)

;values of each checkbox
GuiSetState()
$Checkbox1_val = 1
;$Checkbox2_val = 0
$Checkbox3_val = 2
;$Checkbox4_val = 0
$Checkbox5_val = 4
;$Checkbox6_val = 0
$Checkbox7_val = 8
;$Checkbox8_val = 0
$Checkbox9_val = 16
;$Checkbox10_val = 0
$Checkbox11_val = 32
;$Checkbox12_val = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Button1
            $total = 0
            
            For $X = 1 to 12 Step 2
                If IsChecked(Eval("Checkbox" & $X)) Then 
                    $total += Eval("Checkbox" & $X & "_val")
                EndIf
            Next
            MsgBox(0,"",$total)
        
        Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

Func IsChecked($myCheckbox)
    If BitAnd(GUICtrlRead($myCheckbox),$GUI_CHECKED) = $GUI_CHECKED Then
        Return True
    Else
        Return False
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

THanks a lot !

It worked as hoped.

It is in fact a magic trick featuring my caricatures. Pick out a caricature ,and check the boxes on wich you see it. when ready, click OK, and a splaxh window shows the caricature you had in mind...

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.9.14 (beta)

Author: Hanzz

Script Function:programma om caricaturen aan te wijzen die een ander in gedachten had.

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <GUIConstants.au3>

$Form1 = GUICreate("HANZZ", 831, 713, 60, 0)

$Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_1.jpg", 16, 8, 305, 209, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic2 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_2.jpg", 352, 8, 308, 212, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic3 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_4.jpg", 16, 240, 305, 209, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Checkbox1 = GUICtrlCreateCheckbox("JA", 120, 216, 41, 17)

$Checkbox2 = GUICtrlCreateCheckbox("NEE", 168, 216, 49, 17)

$Checkbox3 = GUICtrlCreateCheckbox("JA", 456, 224, 49, 17)

$Checkbox4 = GUICtrlCreateCheckbox("NEE", 496, 224, 49, 17)

$Pic4 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_8.jpg", 352, 240, 305, 209, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic5 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_16.jpg", 16, 472, 305, 209, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Pic6 = GUICtrlCreatePic("C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\kaartnr_32.jpg", 352, 472, 305, 209, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))

$Checkbox5 = GUICtrlCreateCheckbox("JA", 128, 448, 41, 17)

$Checkbox6 = GUICtrlCreateCheckbox("NEE", 176, 448, 49, 17)

$Checkbox7 = GUICtrlCreateCheckbox("JA", 440, 448, 41, 17)

$Checkbox8 = GUICtrlCreateCheckbox("NEE", 496, 448, 49, 17)

$Checkbox9 = GUICtrlCreateCheckbox("JA", 128, 680, 41, 17)

$Checkbox10 = GUICtrlCreateCheckbox("NEE", 168, 680, 49, 17)

$Checkbox11 = GUICtrlCreateCheckbox("JA", 472, 680, 33, 17)

$Checkbox12 = GUICtrlCreateCheckbox("NEE", 504, 680, 49, 17)

$Group1 = GUICtrlCreateGroup("", 672, 72, 145, 241)

$Label1 = GUICtrlCreateLabel("Kies een caricatuur.", 688, 120, 98, 17)

$Label2 = GUICtrlCreateLabel("Duid bij elke kaart aan", 688, 208, 110, 17)

$Label3 = GUICtrlCreateLabel("of ze ja of nee , erop staat", 680, 224, 127, 17)

$Label4 = GUICtrlCreateLabel("en klik nadien op start", 688, 248, 108, 17)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Button1 = GUICtrlCreateButton("START", 680, 352, 129, 121, 0)

GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif")

GUISetState(@SW_SHOW)

;values of each checkbox

GuiSetState()

$Checkbox1_val = 1

;$Checkbox2_val = 0

$Checkbox3_val = 2

;$Checkbox4_val = 0

$Checkbox5_val = 4

;$Checkbox6_val = 0

$Checkbox7_val = 8

;$Checkbox8_val = 0

$Checkbox9_val = 16

;$Checkbox10_val = 0

$Checkbox11_val = 32

;$Checkbox12_val = 0

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $Button1

$total = 0

For $X = 1 to 12 Step 2

If IsChecked(Eval("Checkbox" & $X)) Then

$total += Eval("Checkbox" & $X & "_val")

EndIf

Next

SplashImageOn("you chose","C:\Documents and Settings\Deconinck Hans\Mijn documenten\autoit\helderziend\" & $total & ".jpg",100,100)

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

Func IsChecked($myCheckbox)

If BitAnd(GUICtrlRead($myCheckbox),$GUI_CHECKED) = $GUI_CHECKED Then

Return True

Else

Return False

EndIf

EndFunc

To make this work you also need some files, mail me(hans.caricatures ATyahoo.com) should you want them.

63 tiny separate pictures (same as in the rasters) to show the chosen caricature.

Have fun !

post-10677-1204570247_thumb.jpg

post-10677-1204570263_thumb.jpg

post-10677-1204570279_thumb.jpg

Share this post


Link to post
Share on other sites

When I compile it, it does not include those pictures.

So ,when I give the exe file to someone else, it doesn't show any pictures...

Can that be helped ?

Share this post


Link to post
Share on other sites

You have to use FileInstall(). You should move all of the pictures into a subfolder where your script is first.

At the top of your script add this:

$subfolder = "pics"

FileInstall("pics\kaartnr_1.jpg", $subfolder & "\kaartnr_1.jpg")

FileInstall("pics\kaartnr_2.jpg", $subfolder & "\kaartnr_2.jpg")

FileInstall("pics\kaartnr_4.jpg", $subfolder & "\kaartnr_4.jpg")

FileInstall("pics\kaartnr_8.jpg", $subfolder & "\kaartnr_8.jpg")

FileInstall("pics\kaartnr_16.jpg", $subfolder & "\kaartnr_16.jpg")

FileInstall("pics\kaartnr_32.jpg", $subfolder & "\kaartnr_32.jpg")

Then each time you need to use GUICtrlCreatePic() you can do this:

GUICtrlCreatePic($subfolder & "\kaartnr_1.jpg")

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