Jump to content

_WaitButton


broodplank
 Share

Recommended Posts

This udf creates a button that count from whatever you want to 1 and then enables the button (could be useful for trials to let the ppl wait some sec :whistle:)

Usage:

_WaitButton($text, $left, $top, $width, $height, $time)

Example:

_WaitButton("Try", 5, 5, 60, 20, 10)

UDF:

;BY BROODPLANK
Func _WaitButton($text, $left, $top, $width, $height, $time)
$button = GUICtrlCreateButton($text, $left, $top, $width, $height, $WS_DISABLED)
$i = $time + 1
Do
    $i -= 1
    GUICtrlSetData($button, $i, $i)
    sleep(1000)

    if $i =  1 then 
        GUICtrlSetData($button, $text)
        GUICtrlSetStyle($button, "")
    EndIf

Until $i = 1
EndFunc

Working Example:

#include <Guiconstants.au3>
$button = ""

GUICreate("WAITBUTTON TEST", 200, 50)

GUISetState()

GUICtrlCreateLabel("Please wait until you can use this trial", 5, 5)

_WaitButton("Try", 5, 25, 60, 20, 10)

While 1
    $msg = GUIGetMsg()
    if $msg = $gui_event_close then Exit
    if $msg = $button then MsgBox(0, "WAITBUTTON", "You can now use this button")
WEnd

Func _WaitButton($text, $left, $top, $width, $height, $time)
$button = GUICtrlCreateButton($text, $left, $top, $width, $height, $WS_DISABLED)
$i = $time + 1
Do
    $i -= 1
    GUICtrlSetData($button, $i, $i)
    sleep(1000)

    if $i =  1 then 
        GUICtrlSetData($button, $text)
        GUICtrlSetStyle($button, "")
    EndIf

Until $i = 1
EndFunc
Edited by broodplank
Link to comment
Share on other sites

nice, here some improvement

Func _WaitButton($text, $left, $top, $width, $height, $time)
    $button = GUICtrlCreateButton($text, $left, $top, $width, $height, $WS_DISABLED)
    GUICtrlSetData($button, $text)
    GUICtrlSetStyle($button, "")
    For $i = $time + 1 To 1 Step -1
        GUICtrlSetData($button, $i, $i)
        Sleep(1000)
    Next
EndFunc   ;==>_WaitButton
My UDF's : Startet on : 06.06.2006_CaseSearchOrReplaceStr();~> Searches OR Replaces a String,;~> With or Without Casesensivity
Link to comment
Share on other sites

  • 2 months later...

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