Jump to content

show clock


 Share

Recommended Posts

Hi

I need to "fix" my script.

The time is jumping back, then forward to the new time.

The exit button in the corner does not work. Can someone help me?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("", 290, 70)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
$sec = ":" & @SEC
$time = @hour & ":" & @MIN
$label1 = GUICtrlCreateLabel ("" & $time, 10, 10)
$label2 = GUICtrlCreateLabel ("" & $sec, 40, 10)

   Select
   
    Case $msg = $GUI_EVENT_CLOSE
   
   
  EndSelect  
WEnd
Link to comment
Share on other sites

Hi GtHoo,

Create you labels before you enter the inifinite loop and set the data via GuiCtrlSetData.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("", 290, 70)
$label1 = GUICtrlCreateLabel ("", 10, 10)
$label2 = GUICtrlCreateLabel ("", 40, 10)

GUISetState(@SW_SHOW)
While 1
    $sec = ":" & @SEC
    $time = @hour & ":" & @MIN

    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect  
    GUICtrlSetData($label1, $time)
    GUICtrlSetData($label2, $sec)
WEnd
Edited by hannes08
Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

Another option would be this:

#include <GUIConstants.au3>
AutoItSetOption("MustDeclareVars", 1)
AutoItSetOption("WinTitleMatchMode", 4)

Const $BRANCO = 0xffffff
Const $AZUL = 0x0000FF
Const $FONTE = "Arial"
Global $lbl
Local $hGUI
Local $WS_EX_TOPMOST
Local $WS_POPUP

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

$hGUI = GUICreate("Hora", 185, 50, 6, -20, $WS_POPUP, $WS_EX_TOPMOST, 0)
GUISetBkColor($AZUL, $hGUI)
GUISetFont(15, -1, -1, $FONTE)
$lbl = GUICtrlCreateLabel("00:00:00", 0, 0, 180)
GUICtrlSetColor($lbl, $BRANCO)
GUISetState(@SW_SHOWNOACTIVATE)

While 1
    Local $mostra_texto = ""
    $mostra_texto = "CLOCK:  " & @HOUR & ":" & @MIN & ":" & @SEC
    GUICtrlSetData(-1, $mostra_texto)
    WinSetOnTop("Hora", "", 1)
    Sleep(900)
WEnd

Func Fechar()
    HotKeySet("{ESC}", "Fechar")
    Exit
EndFunc
Edited by Belini
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...