Jump to content

closing window.


Guest bijukon
 Share

Recommended Posts

Guest bijukon

Hi,

Having a little trouble closing a window after a certain length of time.

Basically I want to give users a choice on wether they want to proceed with a software install. I have a progress bar indicating timeout. If nothing is selected I want the window to close and proceed with the install.

So a couple of things here really:

When I set up the progress bar, I cant click any buttons (maybe I've coded this wrong), thats why I have disabled them while counting down the activate them once countdown has completed. There probably is a better of doing this. If so, please enlighten.

Also I would like the window to close after a period of time if no option has been selected. Again any guidance would be appreciated.

Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)

GuiCreate("Office 2003 install", 340,150)
$yes = GUISetControl("Button", "Ok", 40,100, 80,30)
$no = GUISetControl("Button", "Cancel", 190,100, 80,30)
GuiSetControl("label", "System is about to install Office 2003. Your current Office version will be removed.  If you would like to upgrade at another time press CANCEL", 10, 10, 320, 70)
$timer = GUISetControl("progress", "progress_1", 40,55, 230,30)
GuiShow()
;GuiWaitClose ()

GUISetControlEx ($yes, 128)
GUISetControlEx ($no, 128)


For $i = 100 to 0 step -5
    sleep(500)
;    ProgressSet( $i, $i & " percent")
;    GUISetControl("progress", "progress_1", 40,55, 230,30)
    GUISetControlEx ($timer, $i)
Next

sleep(500)
GUISetControlEx ($yes, 64)
GUISetControlEx ($no, 64)

$exlp = 0

While 1
$N=GuiMsg ()
$exlp = $exlp + 1
    SELECT 
  Case $n = $yes
    Msgbox(0,0,"ok button has been pressed")
    Exit(0)

  Case $n = $no
    Msgbox(0,0,"EXIT button has been pressed")
        Exit (1)
        
    EndSelect


sleep (100)

Exit(0)
wend

Thanks again

Edited by bijukon
Link to comment
Share on other sites

You have to put the progress-meter stuff in the same loop as GuiMsg().

Here's a rough script that might help you:

;Script generated by AutoBuilder 0.4


Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)
GuiCreate("MyGUI", 392,273,(@DesktopWidth-392)/2, (@DesktopHeight-273)/2 , 0x04CF0000)

Dim $timeout = 10 ;progress meter complete in 10 seconds
Dim $percent

$progress_1 = GUISetControl("progress", "Progress 1", 70, 30, 220, 10)
$label_1 = GUISetControl("label", $timeout, 90, 5, 220, 20)
$button_1 = GUISetControl("button", "Pause", 40, 120, 100, 40)
$button_2 = GUISetControl("button", "Exit", 200, 120, 110, 40)

GuiShow()

While 1
    sleep(100)
    If $percent >= 0 Then
       $percent = $percent + 0.1 * $timeout
       GUISetControlEx ($progress_1, $percent)
       GuiWrite($label_1, 0, (100 - $percent)/$timeout & " seconds remain...")
    EndIf

    $msg = GuiMsg(0)
    Select
    Case $msg = -3
        Exit
    Case $msg = $button_1
        $percent = -1
    Case $msg = $button_2
        Exit
    EndSelect
WEnd
Exit
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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...