Search code examples
vb.netwindows-11

How to display seconds in the system tray of the Windows 11 taskbar


As we know, Microsoft choosed not to display seconds in Windows 11 system tray taskbar. Thus, I decided to create a little tool.

A simple timer and a label to show seconds next to the clock. The code I'm using is:


Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.StartPosition = FormStartPosition.Manual
        Me.Location = New Point(1891, 1029)
        Me.Size = New Size(21, 18)

        Me.TransparencyKey = Color.LightBlue
        Me.BackColor = Color.LightBlue
    End Sub
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Label1.Text = ":" + Format(Now, "ss")
    End Sub
End Class

Always on top property is on true but if I click on the taskbar the form will disappear from there. Is there a way to fix it? thanks


Solution

  • After a while, I decided to keep developing this little tool and for some reasons, the position of the form was moving up everytime there was a notification, so I end up forcing the position using the follow code inside of a System.Timers.Timer object that fires its Timer.Tick event every 0,1 seconds (100 milliseconds)

     Me.StartPosition = FormStartPosition.Manual
            Me.Location = New Point(1897, 1039)
            Me.Size = New Size(21, 18)
            Me.TransparencyKey = Color.LightBlue
            Me.BackColor = Color.LightBlue
            Label1.Text = Format(Now, "ss")
            Me.TopMost = True
    

    Simple, but efficient.