Jump to content
Sign in to follow this  
teunvisser

New to GUI

Recommended Posts

teunvisser

Hi everyone,

I've been working with autoit for a while now, and I've just yesterday started working with GUI.

Since i wanted to make my script a bit more dynamic then it was.

I'm making a script that makes me install all software on a pc in a fast way.

This is what i have so far:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Button_1, $Button_2, $Button_3, $Button_4 ,$msg
    GUICreate("Test", 500, 500)

    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("Quicktime", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("Button Test", 0, -1)
    $Button_3 = GUICtrlCreateButton("Button Test", 0, -1)
    $Button_4 = GUICtrlCreateButton("Button Test", 0, -1)


    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                ;New GUI window should open here but i dont know how to.
                EndSelect   
        EndIf
            Case $msg = $Button_2
                MsgBox(0, 'Testing', 'Button 2 was pressed')
        EndSelect
    WEnd
EndFunc

I want to make something like this:

Posted Image

Would be really great if you guys can help me about, even if its just a bit!

Thanx in advance!,

Teun

Edited by teunvisser

Share this post


Link to post
Share on other sites
hot202

search koda

if u have the full ver of scite then it will be under tools.

then create 2 guis and use GUISetState(@SW_HIDE, $GuiName) 4 the quicktime gui and then when u click the quicktime gui use GUISetState(@SW_Show, $GuiName)

Edited by hot202

Share this post


Link to post
Share on other sites
teunvisser

search koda

koda?

Share this post


Link to post
Share on other sites
hot202

koda?

Koda is a Form(gui) Designer It helps making a gui easier if u dont really know how to make them.

Share this post


Link to post
Share on other sites
teunvisser

Koda is a Form(gui) Designer It helps making a gui easier if u dont really know how to make them.

thanx hot, i've tryed it out and it is indeed a really handy program.

But i still dont know how to make 2 GUI screens work together.

Like when u click a button on 1 GUI screen, a second GUI screen opens which gives u more options on the perticulair button.

Share this post


Link to post
Share on other sites
hot202

really quick example there is diff ways to do it.

#include <GUIConstantsEx.au3>




    $gui1 = GUICreate("Test", 500, 500)
    $Button_1 = GUICtrlCreateButton("Quicktime", 10, 30, 100)
    GUISetState(@SW_SHOW, $gui1)


    $gui2 = GUICreate("Test2", 300, 200)
    GUISetState(@SW_HIDE, $gui2)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                GUISetState(@SW_SHOW, $gui2)
        EndSelect
    WEnd

Share this post


Link to post
Share on other sites
Mikesch

And don't forget to

#include <GuiConstants.au3>

if you try hot202's example in a new window.

If you want the main GUI to close when the second one is shown, use:

#include <guiconstants.au3>

$gui1 = GUICreate("Test", 500, 500)
$Button_1 = GUICtrlCreateButton("Quicktime", 10, 30, 100)
GUISetState(@SW_SHOW, $gui1)


$gui2 = GUICreate("Test2", 300, 200)
GUISetState(@SW_HIDE, $gui2)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            GUISetState(@SW_HIDE, $gui1)
            GUISetState(@SW_SHOW, $gui2)

    EndSelect
WEnd

Share this post


Link to post
Share on other sites
teunvisser

Thanx alot!

ill show you my work so far:

#include <guiconstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Install_Manager = GUICreate("Install Manager", 456, 300, 190, 112)
$Button1 = GUICtrlCreateButton("Quicktime", 72, 48, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Silverlight", 152, 48, 73, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 232, 48, 65, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 304, 48, 65, 25, $WS_GROUP)
GUISetState(@SW_SHOW, $Install_Manager)

$Quicktime = GUICreate("Quicktime", 456, 300, 190, 112)
$Button1q = GUICtrlCreateButton("Install", 80, 56, 81, 25, $WS_GROUP)
$Button2q = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25, $WS_GROUP)
$Button3q = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25, $WS_GROUP)
GUISetState(@SW_HIDE, $Quicktime)

$Silverlight = GUICreate("Silverlight", 456, 300, 190, 112)
$Button1s = GUICtrlCreateButton("Install", 80, 56, 81, 25, $WS_GROUP)
$Button2s = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25, $WS_GROUP)
$Button3s = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25, $WS_GROUP)
GUISetState(@SW_HIDE, $Silverlight)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_SHOW, $Quicktime)
            GUISetState(@SW_HIDE, $Silverlight)
        Case $msg = $Button2
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_HIDE, $Quicktime)
            GUISetState(@SW_SHOW, $Silverlight)
    EndSelect
WEnd

Pretty Sweet :mellow:

Share this post


Link to post
Share on other sites
teunvisser

Thanx alot!

ill show you my work so far:

#include <guiconstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Install_Manager = GUICreate("Install Manager", 456, 300, 190, 112)
$Button1 = GUICtrlCreateButton("Quicktime", 72, 48, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Silverlight", 152, 48, 73, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 232, 48, 65, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Button4", 304, 48, 65, 25, $WS_GROUP)
GUISetState(@SW_SHOW, $Install_Manager)

$Quicktime = GUICreate("Quicktime", 456, 300, 190, 112)
$Button1q = GUICtrlCreateButton("Install", 80, 56, 81, 25, $WS_GROUP)
$Button2q = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25, $WS_GROUP)
$Button3q = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25, $WS_GROUP)
GUISetState(@SW_HIDE, $Quicktime)

$Silverlight = GUICreate("Silverlight", 456, 300, 190, 112)
$Button1s = GUICtrlCreateButton("Install", 80, 56, 81, 25, $WS_GROUP)
$Button2s = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25, $WS_GROUP)
$Button3s = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25, $WS_GROUP)
GUISetState(@SW_HIDE, $Silverlight)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_SHOW, $Quicktime)
            GUISetState(@SW_HIDE, $Silverlight)
        Case $msg = $Button2
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_HIDE, $Quicktime)
            GUISetState(@SW_SHOW, $Silverlight)
    EndSelect
WEnd

Pretty Sweet :mellow:

Now here is a script to check if a program is installed:

Const $INSTALLSTATE_ABSENT = 2, $INSTALLSTATE_ADVERTISED = 1
Const $INSTALLSTATE_DEFAULT = 5, $INSTALLSTATE_INVALIDARG = -2
Const $INSTALLSTATE_UNKNOWN = -1

$prodName = "Microsoft Office Professional Editie 2003"
$prodCode = "{90110413-6000-11D3-8CFE-0150048383C9}"
$IsInstalled = DllCall("msi.dll", "int", "MsiQueryProductStateA", "str", $prodCode)
Select
    Case $IsInstalled[0] = $INSTALLSTATE_ABSENT
        $msg = " is installed for a different user."
    Case $IsInstalled[0] = $INSTALLSTATE_ADVERTISED
        $msg = " is advertised."
    Case $IsInstalled[0] = $INSTALLSTATE_UNKNOWN
        $msg = " is not installed."
    Case $IsInstalled[0] = $INSTALLSTATE_DEFAULT
        $msg = " is installed."
    Case Else
        $msg = ": The program's install state could not be determined."
EndSelect
MsgBox(0, "Install Test", $prodName & $msg)

How would I be able to make this work in a GUI code.

I know its kinda hard.. thats why i'm asking you guys!

Tnx for any help u can give me,

Teun

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  

×