Jump to content
Sign in to follow this  
GraaF1337

Updating time

Recommended Posts

GraaF1337

Im trying to make the time show on my GUI, and it shows up just fine, but it wont update.

If i start the GUI at 22:23 the clock will start at 22:23 even tho the time might be 22:25

$aclock = 1
if $aclock = 1 Then


$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)

EndIf

Am i missing something here?.. o.O

Share this post


Link to post
Share on other sites
computergroove

What you wrote only shows what the time is when you start the program. Add a While loop.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
Jos

Create the label one time and then fo a GuiCtrlSetData() to update it in an Adlibregister() func.

Only do that AdlibRegister() one time, so not in a loop.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
GraaF1337

Create the label one time and then fo a GuiCtrlSetData() to update it in an Adlibregister() func.

Only do that AdlibRegister() one time, so not in a loop.

Jos

Im not sure if i understod you right, but you want me to do it like this?

Func Clock()
$aclock = 1
if $aclock = 1 Then


$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)
GUICtrlSetData($clock, _NowTime())
EndIf
EndFunc


While 1
   AdlibRegister("Clock", 1)
   Sleep(1)
   AdlibRegister("Clock", 1)
WEnd

o.O

Share this post


Link to post
Share on other sites
Jos

I mean something like this

; define your gui here
$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)

AdlibRegister("Clock", 800)

While 1
   Sleep(20)
WEnd


Func Clock()
    GUICtrlSetData($clock, _NowTime())
EndFunc

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
GraaF1337

I mean something like this

; define your gui here
$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)

AdlibRegister("Clock", 800)

While 1
   Sleep(20)
WEnd


Func Clock()
    GUICtrlSetData($clock, _NowTime())
EndFunc

Jos

Just tried:

Still doesn't work :-/

$aclock = 1
if $aclock = 1 Then


$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)
EndIf


While 1
   AdlibRegister("Clock", 800)
   sleep(1)
WEnd



Func Clock()
    GUICtrlSetData($clock, _NowTime())
EndFunc

Share this post


Link to post
Share on other sites
GraaF1337

It's standard practice to have a gui before adding controls to a gui.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <NomadMemory.au3>
#include <WinApi.au3>
#include <SecurityConstants.au3>
#include <Security.au3>
#include <WinAPIEx.au3>
#include <Constants.au3>
#include <Console.au3>
#include <GDIPlus.au3>
#include <Security.au3>
#include <WinAPIEx.au3>
#include <Date.au3>

HotKeySet("{ESC}","_Exit")


$Form1 = GUICreate("Clock Test", 614, 536, 597, 271)
GUISetState(@SW_SHOW)



$aclock = 1
if $aclock = 1 Then


$clock = GUICtrlCreateLabel ( _NowTime(), 100, 40, 50, 60)
GUICtrlSetFont($clock, 15, 800, 4)
GUICtrlSetColor($clock, $COLOR_RED)
EndIf


While 1
   AdlibRegister("Clock", 800)
   sleep(1)
WEnd



Func Clock()
    GUICtrlSetData($clock, _NowTime())
EndFunc

Func _Exit()
    Exit
EndFunc

Still doesn't work o.O

Share this post


Link to post
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
Sign in to follow this  

×