Jump to content

2 questions about GUI


Recommended Posts

Hi,

I've been working on this piece of code for a week or 2 now.

But i'm really stuck now, and need some further instructions.

Question 1:

In my script i've created a "back button".

I've tried a few diffrent methods of using it but it doesn't seem to work properly.

When the back button is clicked it needs to return to the main screen which is variable: $Install_Manager

But I cant seem to get it working whatever I do, anyone got some idea's?

Question 2:

In my script I obviously want to make multiple buttons work.

The Quicktime button works now but the Silverlight button (for example) doesn't.

I dont know how to make this work.

Anyone?

And oow yes, my script:

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

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

$Quicktime = GUICreate("Quicktime", 456, 300, 190, 112)
GUISetBkColor(0xE0FFFF)
$Label1q = GUICtrlCreateLabel("", 200, 30, 156, 17)
$Button1q = GUICtrlCreateButton("Install", 80, 56, 81, 25)
$Button2q = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25)
$Button3q = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25)
$Back_Button = GUICtrlCreateButton("Back", 8, 8, 33, 17)
GUISetState(@SW_HIDE, $Quicktime)

$Silverlight = GUICreate("Silverlight", 456, 300, 190, 112)
GUISetBkColor(0xE0FFFF)
$Label1s = GUICtrlCreateLabel("", 200, 30, 156, 17)
$Button1s = GUICtrlCreateButton("Install", 80, 56, 81, 25)
$Button2s = GUICtrlCreateButton("Reinstall", 184, 56, 73, 25)
$Button3s = GUICtrlCreateButton("Deinstall", 280, 56, 65, 25)
$Back_Button = GUICtrlCreateButton("Back", 8, 8, 33, 17)
GUISetState(@SW_HIDE, $Silverlight)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        
        Case $msg = $Back_Button
            GUIDelete ([$Quicktime])
            GUICreate ([$Install_Manager])
            
        Case $msg = $Button1
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_SHOW, $Quicktime)
            GUISetState(@SW_HIDE, $Silverlight)
            
                    $Installcheck = FileExists(@ProgramFilesDir & "\Quicktime")
                    If $Installcheck = 1 Then
                            GUICtrlSetData($Label1q, "is installed")
                    EndIf
                    If $Installcheck = 0 Then
                            GUICtrlSetData($Label1q, "is not installed")
                    EndIf
        Case $msg = $Button1q
            Run("\\pdc-skoba\appsg\Redist\Apple\QuickTime\7.6.5\QuickTimeInstaller.exe /Q")
        Case $msg = $Button2q
            Run("\\pdc-skoba\appsg\Redist\Apple\QuickTime\7.6.5\QuickTimeInstaller.exe")
                WinWaitActive("QuickTime voor Windows")
                Send("{ENTER}")
                WinWaitActive("QuickTime voor Windows", "&Voltooien")
                Send("{ENTER}")
        Case $msg = $Button3q
            Run("\\pdc-skoba\appsg\Redist\Apple\QuickTime\7.6.5\QuickTimeInstaller.exe")
                WinWaitActive("QuickTime voor Windows")
                Send("{TAB}")
                Send("{ENTER}")
                Sleep(5000)
                Send("{ENTER}")
                WinWaitActive("QuickTime voor Windows", "&Voltooien")
                Send("{ENTER}")
    EndSelect
WEnd

While 2
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $Button2
            GUISetState(@SW_HIDE, $Install_Manager)
            GUISetState(@SW_HIDE, $Quicktime)
            GUISetState(@SW_SHOW, $Silverlight)
            
                    $Installcheck = FileExists(@ProgramFilesDir & "\Microsoft Silverlight")
                    If $Installcheck = 1 Then
                            GUICtrlSetData($Label1s, "is installed")
                    EndIf
                    If $Installcheck = 0 Then
                            GUICtrlSetData($Label1s, "is not installed")
                    EndIf
        Case $msg = $Button1s
            Run("\\pdc-skoba\AppsG\Redist\Microsoft\Silverlight.3\Silverlight.exe /Q")  
        Case $msg = $Button2s
        
        Case $msg = $Button3s
        
    EndSelect
WEnd

Hope I can get some help from u guys,

Thanx in advance,

Teun

Link to comment
Share on other sites

A few problems:

1.

Remove the square brackets from:

GUIDelete ([$Quicktime])
GUICreate ([$Install_Manager])

(line 40 & 41)

2.

On line 21 you create a button and store it's identifier as $Back_Button.

On line 30 you create a different button and use the same variable overwriting the identifier from the button created on line 21.

As a result line 39 only compares $msg to the button created on line 30, making the button on line 21 unresponsive.

One way to fix it would be to use different variables to store each control ID.

3.

On line 41 you create a new, empty GUI. Instead you can use "GUISetState(@SW_SHOW, $Install_Manager)" to make the existing one visible.

edit:

4.

Only just realised you're using multiple GUIGetMsg() while loops. Try to combine them into a single loop as the second one is only called after trying to close the GUI once.

(try clicking the "x" on the top right once. The silverlight button suddenly starts working.

Hope it helps

Edited by Tvern
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...