Is there a way to get a list of all the applications represented by the system tray icons ? For example, I would like to get, for each of them :
- Application name
- Application state (minimized or not)
- System Tray Icon absolute coordinates
Thanks...
snakedjip
December 15th, 1999, 12:31 PM
Hello,
Is there a way to get a list of all the applications represented by the system tray icons ? For example, I would like to get, for each of them :
- Application name
- Application state (minimized or not)
- System Tray Icon absolute coordinates
Thanks...
snakedjip
December 15th, 1999, 12:31 PM
Hello,
Is there a way to get a list of all the applications represented by the system tray icons ? For example, I would like to get, for each of them :
- Application name
- Application state (minimized or not)
- System Tray Icon absolute coordinates
Thanks...
Lothar Haensler
December 16th, 1999, 01:48 AM
I'd use FindWindow API to find the system tray window:
hwnd = FindWindow("Shell_TrayWnd", vbNullString)
Then, enumerate all children of that window using EnumChildWindows.
Then, for each child
- call GetWindowText to get the application title
- call IsIconic to find out if it is minimized
- call GetWindowRect to get the position of the window
snakedjip
December 16th, 1999, 09:02 PM
Close, but not quite right...
Here's the window tree I get when I call EnumChildWindows recursively on "Shell_TrayWnd" :
Child Class = Button, Title = , L: 2, R: 56
Child Class = TrayNotifyWnd, Title = , L: 856, R: 1022
+++++Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = MSTaskSwWClass, Title = , L: 60, R: 852
+++++Child Class = SysTabControl32, Title = , L: 60, R: 852
Child Class = SysTabControl32, Title = , L: 60, R: 852
I see the TrayNotifyWnd window going from horizontal coordinates 856 to 1022 (in a 1024*768 resolution), but calling EnumChildWindows on that window results in only ONE child, the TrayClockWClass window, going from horizontal coordinates 961 to 1022.
How do I get access to the icons, which are obviously between horizontal coordinates 856 and 960 ?
Unless my code to get recursive windows is bugged... Here's the callback function for the EnumChildWindows API function:
Function enumRecursif(byval lhWnd as Long, byval lParam as Long) as Long
Dim RetVal as Long
Dim WinClassBuf as string * 255, WinTitleBuf as string * 255
Dim WinClass as string, WinTitle as string
Dim WinRect as RECT
Dim WinWidth as Long, WinHeight as Long
Dim tmpText as string
Dim i as Long
Dim ThreadId as Long
RetVal = GetClassName(lhWnd, WinClassBuf, 255)
WinClass = StripNulls(WinClassBuf) ' remove extra Nulls & spaces
RetVal = GetWindowText(lhWnd, WinTitleBuf, 255)
WinTitle = StripNulls(WinTitleBuf)
RetVal = GetWindowRect(lhWnd, WinRect)
for i = 1 to lParam * 5
tmpText = tmpText & " "
next i
tmpText = tmpText & "Child Class = " & WinClass & ", Title = " & WinTitle & ", L: " & WinRect.Left & ", R: " & WinRect.Right
Debug.print tmpText
Call WrapperRecursif(lhWnd, lParam + 1)
enumRecursif = true
End Function
Sub WrapperRecursif(byval lhWnd as Long, lParam as Long)
Dim RetVal as Long
RetVal = EnumChildWindows(lhWnd, AddressOf enumRecursif, lParam)
End Sub
snakedjip
December 16th, 1999, 09:02 PM
Close, but not quite right...
Here's the window tree I get when I call EnumChildWindows recursively on "Shell_TrayWnd" :
Child Class = Button, Title = , L: 2, R: 56
Child Class = TrayNotifyWnd, Title = , L: 856, R: 1022
+++++Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = MSTaskSwWClass, Title = , L: 60, R: 852
+++++Child Class = SysTabControl32, Title = , L: 60, R: 852
Child Class = SysTabControl32, Title = , L: 60, R: 852
I see the TrayNotifyWnd window going from horizontal coordinates 856 to 1022 (in a 1024*768 resolution), but calling EnumChildWindows on that window results in only ONE child, the TrayClockWClass window, going from horizontal coordinates 961 to 1022.
How do I get access to the icons, which are obviously between horizontal coordinates 856 and 960 ?
Unless my code to get recursive windows is bugged... Here's the callback function for the EnumChildWindows API function:
Function enumRecursif(byval lhWnd as Long, byval lParam as Long) as Long
Dim RetVal as Long
Dim WinClassBuf as string * 255, WinTitleBuf as string * 255
Dim WinClass as string, WinTitle as string
Dim WinRect as RECT
Dim WinWidth as Long, WinHeight as Long
Dim tmpText as string
Dim i as Long
Dim ThreadId as Long
RetVal = GetClassName(lhWnd, WinClassBuf, 255)
WinClass = StripNulls(WinClassBuf) ' remove extra Nulls & spaces
RetVal = GetWindowText(lhWnd, WinTitleBuf, 255)
WinTitle = StripNulls(WinTitleBuf)
RetVal = GetWindowRect(lhWnd, WinRect)
for i = 1 to lParam * 5
tmpText = tmpText & " "
next i
tmpText = tmpText & "Child Class = " & WinClass & ", Title = " & WinTitle & ", L: " & WinRect.Left & ", R: " & WinRect.Right
Debug.print tmpText
Call WrapperRecursif(lhWnd, lParam + 1)
enumRecursif = true
End Function
Sub WrapperRecursif(byval lhWnd as Long, lParam as Long)
Dim RetVal as Long
RetVal = EnumChildWindows(lhWnd, AddressOf enumRecursif, lParam)
End Sub
snakedjip
December 16th, 1999, 09:02 PM
Close, but not quite right...
Here's the window tree I get when I call EnumChildWindows recursively on "Shell_TrayWnd" :
Child Class = Button, Title = , L: 2, R: 56
Child Class = TrayNotifyWnd, Title = , L: 856, R: 1022
+++++Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = TrayClockWClass, Title = , L: 961, R: 1022
Child Class = MSTaskSwWClass, Title = , L: 60, R: 852
+++++Child Class = SysTabControl32, Title = , L: 60, R: 852
Child Class = SysTabControl32, Title = , L: 60, R: 852
I see the TrayNotifyWnd window going from horizontal coordinates 856 to 1022 (in a 1024*768 resolution), but calling EnumChildWindows on that window results in only ONE child, the TrayClockWClass window, going from horizontal coordinates 961 to 1022.
How do I get access to the icons, which are obviously between horizontal coordinates 856 and 960 ?
Unless my code to get recursive windows is bugged... Here's the callback function for the EnumChildWindows API function:
Function enumRecursif(byval lhWnd as Long, byval lParam as Long) as Long
Dim RetVal as Long
Dim WinClassBuf as string * 255, WinTitleBuf as string * 255
Dim WinClass as string, WinTitle as string
Dim WinRect as RECT
Dim WinWidth as Long, WinHeight as Long
Dim tmpText as string
Dim i as Long
Dim ThreadId as Long
RetVal = GetClassName(lhWnd, WinClassBuf, 255)
WinClass = StripNulls(WinClassBuf) ' remove extra Nulls & spaces
RetVal = GetWindowText(lhWnd, WinTitleBuf, 255)
WinTitle = StripNulls(WinTitleBuf)
RetVal = GetWindowRect(lhWnd, WinRect)
for i = 1 to lParam * 5
tmpText = tmpText & " "
next i
tmpText = tmpText & "Child Class = " & WinClass & ", Title = " & WinTitle & ", L: " & WinRect.Left & ", R: " & WinRect.Right
Debug.print tmpText
Call WrapperRecursif(lhWnd, lParam + 1)
enumRecursif = true
End Function
Sub WrapperRecursif(byval lhWnd as Long, lParam as Long)
Dim RetVal as Long
RetVal = EnumChildWindows(lhWnd, AddressOf enumRecursif, lParam)
End Sub
Ravi Kiran
December 17th, 1999, 05:20 AM
At the first look, i am confused, why is there a call to
Call WrapperRecursif(lhWnd, lParam + 1)
in the Function enumRecursif ?? (in the last but 2 line)!!
This function need not call the Wraperxxx again.. One call to EnumChildWindows will call this enumRecuseif function, passing each window handle of the child windows.
To proceed you need to return True, or return false to stop. You dont need to call the function again & again.
Well this is at the first look, excuse me if i overlooked something!...
RK
Ravi Kiran
December 17th, 1999, 05:42 AM
Ok. sorry , i was too fast.. unnecesarily..
You want enumeration, lover levels.. intentional.
Sorry again.
RK
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.