Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Icon exists in systray?

I want to check if an icon exists in the systray; as in, if "X" application has displayed their systray icon in the systray area.

I've Googled for information about how to do this but I didn't find anything.

UPDATE :

This what I've tried in VB.NET translating the C# examples of the url gived by Robert comment, but I don't know how to continue it.

Imports System.Runtime.InteropServices

Public Class Form1

    Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

    Public Shared Function WindowHandle(sTitle As String) As Long
        Return FindWindow(vbNullString, sTitle)
    End Function


    Private Shared Function GetSystemTrayHandle() As IntPtr
        Dim hWndTray As IntPtr = FindWindow("Shell_TrayWnd", Nothing)
        If hWndTray <> IntPtr.Zero Then
            hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "TrayNotifyWnd", Nothing)
            If hWndTray <> IntPtr.Zero Then
                hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "SysPager", Nothing)
                If hWndTray <> IntPtr.Zero Then
                    hWndTray = FindWindowEx(hWndTray, IntPtr.Zero, "ToolbarWindow32", Nothing)
                    Return hWndTray
                End If
            End If
        End If

        Return IntPtr.Zero
    End Function

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox(WindowHandle("Steam")) ' 6687230
        MsgBox(GetSystemTrayHandle()) ' 62789
    End Sub

End Class
like image 552
ElektroStudios Avatar asked Apr 09 '13 17:04

ElektroStudios


People also ask

Why can’t I see icons on my System Tray?

Note: Icons in the system tray only appear when their corresponding apps are running. If you still don’t see icons on your system tray, use the Turn system icons on or off setting and see if it helps. To do this, right-click the Taskbar > Taskbar Settings. In the Taskbar Settings, go to the Notification area and select Turn system icons on or off.

How do I hide an icon in the system tray?

The easiest way to hide an icon that you don’t want to see in the System Tray is to reverse the previous section's process. Click and hold an icon in the System Tray. Drag the icon to the ^ icon. Position the icon where you want it in the expanded System Tray. Release the left mouse button.

How do I add icons to the system tray in Windows 10?

Click and hold an icon from the expanded System Tray. Drag the icon into the standard System Tray. Release the left mouse button. If you don’t like the positioning of the icon, you can click and drag it left or right to position it where you want it in the tray.

How do I enable system icons on the taskbar?

Go to the Notification area section from the Taskbar settings again and click or tap the "Turn system icons on or off" link. Access Turn system icons on or off Choose which system icons are enabled by turning on the switch next to them. Turn On the system icons that you want to enable


1 Answers

You should read this code-project article.

like image 63
Screitor Avatar answered Sep 28 '22 23:09

Screitor