Jump to content

Updating time


 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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