Is there a way to put a status text into the Windows taskbar notification area?

I’d like to show a short status text in the Windows notification area, so not an icon, but a text of a few characters the content of which changes regularly and comes from a text file.

Is there a simple way to put such a text into the notification area?


Thanks to @LotPings who pointed me to an other answer, I managed to create a VB script which regularly reads text from a file and displays it in the notification area (the 29 on the picture).

enter image description here

Currently it’s only two characters, but you can use a smaller font to display more.

Note that I’m not a Windows programmer, nor a VB programmer, so the code is not pretty, I just copy pasted from examples until I made it work.

Here’s the code which you can compile with vbc.exe (e.g. C:WindowsMicrosoft.NETFramework64v4.0.30319vbc.exe):

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Timers

Public NotInheritable Class Form1
    Inherits System.Windows.Forms.Form

    Private contextMenu1 As System.Windows.Forms.ContextMenu
    Friend WithEvents menuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents notifyIcon1 As System.Windows.Forms.NotifyIcon
    Private components As System.ComponentModel.IContainer

    Private fontToUse As System.Drawing.Font
    Private brushToUse As System.Drawing.Brush
    Private bitmapText As System.Drawing.Bitmap
    Private g As System.Drawing.Graphics
    Private hIcon As IntPtr

    Private aTimer As System.Timers.Timer

    <System.STAThread()> _
    Public Shared Sub Main()
        System.Windows.Forms.Application.Run(New Form1)
    End Sub 'Main

    Public Sub New()

        Me.components = New System.ComponentModel.Container
        Me.contextMenu1 = New System.Windows.Forms.ContextMenu
        Me.menuItem1 = New System.Windows.Forms.MenuItem

        ' Initialize contextMenu1
        Me.contextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() _

        ' Initialize menuItem1
        Me.menuItem1.Index = 0
        Me.menuItem1.Text = "E&xit"

        ' Set up how the form should be displayed.
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Text = "Notify Icon Example"

        ' Create the NotifyIcon.
        Me.notifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
        notifyIcon1.ContextMenu = Me.contextMenu1

        aTimer = New System.Timers.Timer(300000)
        AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
        aTimer.AutoReset = True
        aTimer.Enabled = True


        Me.WindowState = FormWindowState.Minimized
        Me.ShowInTaskbar = False

End Sub 'New

    Private Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
        'Console.WriteLine("The Elapsed event was raised at {0:HH:mm:ss.fff}",
        '                  e.SignalTime)


    End Sub

    Private Sub UpdateIcon
        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText("c:temp.txt")

        fontToUse = New Font("Microsoft Sans Serif", 16, FontStyle.Regular, GraphicsUnit.Pixel)
        brushToUse = New SolidBrush(Color.White)
        bitmapText = new Bitmap(16, 16)
        g = Drawing.Graphics.FromImage(bitmapText)
        g.DrawString(fileReader, fontToUse, brushToUse, -4, -2)
        hIcon = (bitmapText.GetHicon)
        Me.notifyicon1.Icon = Drawing.Icon.FromHandle(hIcon)
        notifyIcon1.Visible = True

    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        ' Clean up any components being used.
        If disposing Then
            If (components IsNot Nothing) Then
            End If
        End If
    End Sub 'Dispose

    Private Sub notifyIcon1_DoubleClick(Sender as object, e as EventArgs) handles notifyIcon1.DoubleClick
        ' Show the form when the user double clicks on the notify icon.

        ' Set the WindowState to normal if the form is minimized.
        if (me.WindowState = FormWindowState.Minimized) then _
            me.WindowState = FormWindowState.Normal

        ' Activate the form.
    end sub

    Private Sub menuItem1_Click(Sender as object, e as EventArgs) handles menuItem1.Click
        ' Close the form, which closes the application.
    end sub

End Class 'Form1