Jump to content

Checkboxes for executing files in a nice windows


Iznogoud
 Share

Recommended Posts

Hi,

I am trying to make a GUI so i can install some programs with it wich are checked etc.

I have a company logo, below the logo i have 5 checkboxes wich will increase in the future.

For each checkbox is a different installer, so when you start the program you can choose wich you want to execute etc.

I am trying to make this with the help etc. and combine all sorts of scripts, but i can't get it to work.

Maybe you guys could help me a bit.

This is my code:

#include <GUIConstants.au3>
GUICreate("Windows Xp Instellingen",499,488,-1,-1,)

GUISetBkColor (0xFFFFFF)
$n=GUICtrlCreatePic("<path>\logo1.jpg",0,0, 499,160)
$n=GUICtrlCreatePic("<path>\logo2.jpg",0,380, 499,88)

GUISetState ()

$treeone =  GuiCtrlCreateTreeView(25, 220, 0, 20, $TVS_CHECKBOXES)
$treetwo =  GuiCtrlCreateTreeView(25, 240, 0, 20, $TVS_CHECKBOXES)
$treethree =    GuiCtrlCreateTreeView(25, 260, 0, 20, $TVS_CHECKBOXES)
$treefour =     GuiCtrlCreateTreeView(25, 280, 0, 20, $TVS_CHECKBOXES)
$treefive =     GuiCtrlCreateTreeView(25, 300, 0, 20, $TVS_CHECKBOXES)

GuiCtrlCreateTreeViewItem("1.", $treeone)
GuiCtrlCreateTreeViewItem("2.", $treetwo)
GuiCtrlCreateTreeViewItem("3.", $treethree)
GuiCtrlCreateTreeViewItem("4.", $treefour)
GuiCtrlCreateTreeViewItem("5.", $treefive)

$okbutton  = GUICtrlCreateButton ("Uitvoeren",200,340,70,20)


Select
    Case $treeone = 1
    Run("1.exe")
    Case $treetwo = 1
    Run("2.exe")
    Case $treethree = 1
    Run("3.exe")
    Case $treefour = 1
    Run("4.exe")
    Case $treefive = 1
    Run("5.exe")
    Case Else
    MsgBox(0, "", "TEST")
EndSelect


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Between the OKBUTTON and the CASE there must be a action by pressing the OKBUTTON execute the case.

But i am absolute a beginner with AutoIT and i can't solve this problem on my own i think.

I would appreciate if you guys could help me.

Link to comment
Share on other sites

This is how i would do what i think ur trying to do:

#include <GUIConstants.au3>
GUICreate("Windows Xp Instellingen",499,488 )
Func _run($q)
    Select
    Case $q = 0
        Msgbox ( 0 , '' , 'Program 1' )
    Case $q = 1
        Msgbox ( 0 , '' , 'Program 2' )
    Case $q = 2
        Msgbox ( 0 , '' , 'Program 3' )
    EndSelect
EndFunc
GUISetState ()
Opt ( 'GUICoordMode' , 2 )
Dim $a[3]
$a[0]=GUICtrlCreateCheckbox ( '1' , 5 , 5 )
$a[1]=GUICtrlCreateCheckbox ( '2' , -1 , 2 )
$a[2]=GUICtrlCreateCheckbox ( '3' , -1 , 2 )

Opt ( 'GUICoordMode' , 1 )
$okbutton  = GUICtrlCreateButton ("Uitvoeren",200,340,70,20)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $okbutton
            ExitLoop
    EndSelect
Wend
Dim $o[3]
For $n=0 To 2
    $o[$n]=GUICtrlRead ( $a[$n] )
    If $o[$n]=1 Then _run($n)
Next
Link to comment
Share on other sites

This is how i would do what i think ur trying to do:

#include <GUIConstants.au3>
GUICreate("Windows Xp Instellingen",499,488 )
Func _run($q)
    Select
    Case $q = 0
        Msgbox ( 0 , '' , 'Program 1' )
    Case $q = 1
        Msgbox ( 0 , '' , 'Program 2' )
    Case $q = 2
        Msgbox ( 0 , '' , 'Program 3' )
    EndSelect
EndFunc
GUISetState ()
Opt ( 'GUICoordMode' , 2 )
Dim $a[3]
$a[0]=GUICtrlCreateCheckbox ( '1' , 5 , 5 )
$a[1]=GUICtrlCreateCheckbox ( '2' , -1 , 2 )
$a[2]=GUICtrlCreateCheckbox ( '3' , -1 , 2 )

Opt ( 'GUICoordMode' , 1 )
$okbutton  = GUICtrlCreateButton ("Uitvoeren",200,340,70,20)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $okbutton
            ExitLoop
    EndSelect
Wend
Dim $o[3]
For $n=0 To 2
    $o[$n]=GUICtrlRead ( $a[$n] )
    If $o[$n]=1 Then _run($n)
Next
Yes, at first sight, this is what i mean. I will try to adjust it so my logo's are in it.

But what i dont understand is the last set of code from DIM.

I would like to know hat is happening there, so MAYBE i can learn something off it :lmao:

Link to comment
Share on other sites

I have adjusted the code to this:

Changed some fields wich have restricted information :lmao:

#include <GUIConstants.au3>
GUICreate("Windows Xp Instellingen",499,420 )

Func _run($q)
    Select
    Case $q = 0
           ;execute a program

    Case $q = 1
           ;execute a program

    Case $q = 2
           ;execute a program

    Case $q = 3
           ;execute a program

    Case $q = 4
           ;execute a program    

    Case $q = 5
        RunWait(@ComSpec & " /c " & '"C:\test\test.bat"', "", @SW_HIDE)
    Sleep(1000)

    Case $q = 6
        DirRemove("C:\test\test", 1)
        DirRemove("C:\test\", 1)
        Sleep(1000)

    EndSelect
EndFunc

GUISetState ()
Opt ( 'GUICoordMode' , 2 )
Dim $a[7]
$a[0]=GUICtrlCreateCheckbox ( '1.' , 25 , 170 )
;GUICtrlSetState (-1,1)
$a[1]=GUICtrlCreateCheckbox ( '2.' , -1 , 2 )
;GUICtrlSetState (-1,1)
$a[2]=GUICtrlCreateCheckbox ( '3.' , -1 , 2 )
;GUICtrlSetState (-1,1)
$a[3]=GUICtrlCreateCheckbox ( '4.' , -1 , 2 )
$a[4]=GUICtrlCreateCheckbox ( '5.' , -1 , 2 )
;GUICtrlSetState (-1,1)
$a[5]=GUICtrlCreateCheckbox ( '6.' , -1 , 2 )
$a[6]=GUICtrlCreateCheckbox ( '7.' , -1 , 2 )
GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlSetState(-1,$GUI_DISABLE)


Opt ( 'GUICoordMode' , 1 )
$okbutton  = GUICtrlCreateButton ("Uitvoeren",200,340,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)

GUISetBkColor (0xFFFFFF)
$n1 = GUICtrlCreatePic("C:\test\logo1.jpg",0,0, 499,160)
$n2 = GUICtrlCreatePic("C:\test\logo2.jpg",0,360, 499,88)

If FileExists("C:\test\logo1.JPG" ) Then
;Do nothing
Else
    Exit
EndIf

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            DirRemove("C:\test\test", 1)
            DirRemove("C:\tet\", 1)
            Sleep(1000)
            Exit
        Case $msg = $okbutton
            ExitLoop
    EndSelect
Wend
Dim $o[7]
For $n=0 To 6
    $o[$n]=GUICtrlRead ( $a[$n] )
    If $o[$n]=1 Then _run($n)
Next

I understand a little bit of the last section, i got confused from the variables used.

But i think what is happening is that for its just a loop wich look if a checkbox is activated untill the end.

Is it possible to activate the rule wich is executed at the moment. So if checkbox 1 is installing that you can see the program is busy at checkbox 1?

For an example a change of background color. I have tried to put "GUICtrlSetBkColor(-1,0x00ff00) " at the last action for a function, but this would help. And i tried different places at the last loop wich i didnt understood. But i can't get it to work.

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