Jump to content

Button


GAM
 Share

Recommended Posts

Hi, below is script written to display a message at 12:00AM everyday. Before displaying this message there appears a GUI with xyz message and also a button. Now, I want to include statements in the script such that on clicking this button another message should be displayed. Can anyone helo me out in this please????

--------------------------------------------------------

#include <GUIConstants.au3>

#include <Date.au3>

$Hours = "23"

$Minutes = "59"

$Seconds = "59"

$FirstWarningAfter = "30"

$FirstWarningBefore = "31"

$SecondWarningAfter = "57"

$SecondWarningBefore = "59"

GUICreate("My GUI Progressbar",220,100, 100,200)

GUICtrlSetColor(-1,32250)

$Progressbar = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)

$ShutdownButton = GUICtrlCreateButton ("Dont Shutdown",75,70,100,20)

While 1

$CurHours = @HOUR

$CurMinutes = @MIN

$CurSeconds = @SEC

If ($CurHours = $Hours And $CurMinutes = $Minutes And $CurSeconds = $Seconds) Then

MsgBox(0," ; ", "Its 00:00 AM")

EndIf

If $CurMinutes > $SecondWarningAfter Then

If $CurMinutes <= $SecondWarningBefore Then

For $i = $CurSeconds To 57 Step 1

GUISetState ()

GUICtrlSetData ($Progressbar, (60-$i))

Sleep(1000)

Next

GUIDelete()

EndIf

EndIf

Sleep(50)

WEnd

Neil

Link to comment
Share on other sites

If you're using a Select...Case Loop (which I see you are not. (

tags make it easy to read), just use $msg = $btn, where $msg = GUIGetMsg ().  Then you even goes after.
Link to comment
Share on other sites

Moin Moin,

try this and rebuild it in your way ...

#include <GUIConstants.au3>
#include <Date.au3>

$Hours   = 23
$Minutes = 59
$Seconds = 59
$FirstWarningAfter   = 30
$FirstWarningBefore  = 31
$SecondWarningAfter  = 57
$SecondWarningBefore = 59

Global $iTime = $Hours & $Minutes & $Seconds

$hWnd = GUICreate("My GUI Progressbar",220,100, 100,200)
GUICtrlSetColor(-1,32250)
$Progressbar        = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$ShutdownButton     = GUICtrlCreateButton ("Dont Shutdown",75,70,100,20)

;GUISetState()

While True

    Switch GUIGetMsg()
        Case -3
            Exit
        Case $ShutdownButton
            MsgBox(4096, 'Message', 'Button is pressed ...')
            ;;; go on here ...
    EndSwitch
    ; call your Function
    Time()

WEnd

Func Time()
    
;    Local $CurHours    = @HOUR
;    Local $CurMinutes  = @MIN
    Local $CurSeconds   = @SEC
    Local $iCurrentTime = @HOUR & @MIN & @SEC

;    If ($CurHours = $Hours And $CurMinutes = $Minutes And $CurSeconds = $Seconds) Then
    If $iTime == $iCurrentTime Then
        MsgBox(0," ; ", "Its 00:00 AM")
    EndIf

    If @MIN > $SecondWarningAfter Then
        If @MIN <= $SecondWarningBefore Then
            GUISetState (@SW_SHOW) ; show the GUI before the loop begins
            For $i = $CurSeconds To 57 Step 1
                GUICtrlSetData ($Progressbar, (60-$i))
                Sleep(1000)
            Next
            GUISetState (@SW_HIDE) ; hide the GUI if you want to display it again
;            GUIDelete()
        EndIf
    EndIf
    Sleep(50)
    
EndFunc

Greetz

Greenhorn

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