Sign in to follow this  
Followers 0
GtHoo

show clock

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I did get a new problem. I can't see the whole time. Is it just me, er for you to?

Edited by GtHoo

Share this post


Link to post
Share on other sites

You'll have to set the width and height of your labels as well.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

It works. Tnx ;)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

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  
Followers 0