Jump to content

Add counter within gui


MightyWeird
 Share

Recommended Posts

Hello,

 

I am alwasy struggeling to do multiple things  at the same time.

I have a main screen with a button which calls the function ninite1.

The function "ninite1" then executes and fires a new gui.

The program start to run with the gui (test) in the back ground

 

Now I would like to have a counter (_count() which shows how long this program is running within this gui (ninitegui)

Somebody?

 

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <ColorConstantS.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <InetConstants.au3>

_ninite1()

Func _ninite1()

    GLOBAL  $count = 0

    Local $NINITEGUI = GUICreate("Runtimes", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)
    Local $idLabel2 = GUICtrlCreateLabel("test", 600, 150, @DesktopWidth, 150)
    GLOBAL $lblData = GuICtrlCreateLabel("", 40, 40,50,50)

    _Count()


    Sleep(1000)
    GUISetState(@SW_SHOW, $NINITEGUI)


    Run(@ScriptDir & "\Resources" & "\Runtime\ninite.exe")
    ;Run(@ScriptDir & "\Resources" & "\Runtime\vlcetc.exe")
    While 1
        If ControlCommand("Ninite", "Close", "[CLASS:Button; INSTANCE:1]", "IsEnabled", "") Then
            ControlClick("Ninite", "Close", 2)
            Sleep(15)         ; Important or you eat all the CPU which will not help the defrag!
            ExitLoop
        EndIf
    WEnd

    GUIDelete($NINITEGUI)

EndFunc   ;==>_ninite1


Func _Count()
    For $i = $count To 100
        GuiCtrlSetData($lblData, $i)
        Sleep(1000)
    Next
EndFunc

 

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 4 weeks later...

Hi

Thank you.. took me into the right direction.

Found this code somewhere (can't remember original post)

 

Countdown()
    AdlibRegister("Countdown", 1000)

Func Countdown()
    local $sec, $min, $hr
    $sec = Mod($seconds, 60)
    $min = Mod($seconds / 60, 60)
    $hr = Floor($seconds / 60 ^ 2)
    GUICtrlSetData($labelcounter, StringFormat("%02i:%02i:%02i", $hr, $min, $sec))
    $seconds += 1
EndFunc

 

 

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

×
×
  • Create New...