Page 1 of 1
Posted: Sat Nov 16, 2002 5:46 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
Does anyone know a way to get a list, in order, of all the buttons in
the Windows Taskbar? I just need their caption text, in left-right
order. I've tried using FindWindowEx with the Taskbar's handle but
it doesn't work... and the following is supposed to show how many
buttons are in the Taskbar but it reports 0 all the time:
Code: Select all
hShellTray = FindWindow_("Shell_TrayWnd" , "")
hRebarWindow = FindWindowEx_(hShellTray, 0, "RebarWindow32" , "")
hTaskSwitch = FindWindowEx_(hRebarWindow, 0, "MSTaskSwWClass" , "")
hTaskbar = FindWindowEx_(hTaskSwitch, 0, "SysTabControl32" , "")
ItemCount = SendMessage_(hTaskBar, #TCM_GETITEMCOUNT, 0, 0)
PB - Registered PureBasic Coder
Posted: Sat Nov 16, 2002 6:40 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
You need the tab control handle, wich is a child window of the tray window:
Code: Select all
procedure EnumChildProc(hwnd,lparam)
shared htab
cname$=space(255)
GetClassName_(hwnd,@cname$,255)
if cname$="SysTabControl32"
htab=hwnd
procedurereturn 0
else
procedurereturn 1
endif
endprocedure
hShellTray=FindWindow_("Shell_TrayWnd",#null)
;find tab handle
EnumChildWindows_(hShellTray,@EnumChildProc(),0)
ItemCount=SendMessage_(htab, #TCM_GETITEMCOUNT, 0, 0)
messagerequester("",str(ItemCount),0)
Posted: Sat Nov 16, 2002 6:44 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
Thanks Justin, but after some extensive web searching I came up with
the following, which has
almost achieved my goal:
Code: Select all
taskbar=FindWindow_("Shell_TrayWnd","")
r=FindWindowEx_(taskbar,0,"MSTaskSwWClass","")
tc=FindWindowEx_(r,0,"SysTabControl32","")
i=SendMessage_(tc,#TCM_GETITEMCOUNT,0,0)
Debug Str(i)+" buttons on Taskbar:"
;
For r=1 To i
a$=Space(255)
SendMessage_(@tc,#TCM_GETITEM,r,a$)
Debug Str(r)+" = "+a$
Next
Anyone know why I'm not getting the button captions?
UPDATE: Both Justin and my methods don't work with Win XP...

Posted: Mon May 01, 2006 8:08 pm
by xgp
Hi!
I've searched with all the words i can imagine to get an approach to this, but only found this as most close.
Just wanted to know if someone has an idea on how to archieve this ( listing tray icons ).
Bye!
Posted: Mon May 01, 2006 8:47 pm
by Trond
Theoretically this should work, however it crashes explorer.exe here.
Code: Select all
hTaskbar = FindWindow_("Shell_TrayWnd", "")
hTray = FindWindowEx_(hTaskbar, 0, "TrayNotifyWnd", "")
hTray = FindWindowEx_(hTray, 0, "ToolbarWindow32", "")
; At this point, hTray contains the window handle of the
; system tray! It happens to be a toolbar (!)
;EnumChildWindows_(hTray, @EnumChildProc(), 0)
;Debug EasyClassName(hTray)
Debug "Number of icons:"
Debug SendMessage_(hTray, #TB_BUTTONCOUNT, 0, 0)
For I = 0 To SendMessage_(hTray, #TB_BUTTONCOUNT, 0, 0)
Button.TBBUTTON
Debug SendMessage_(hTray, #TB_GETBUTTON, I, @Button) ; explorer.exe crashes??
Debug "Icon #" + Str(I)
With Button
Debug " " + "iBitmap: " + Str( \iBitmap)
Debug " " + "iCommand: " + Str( \idCommand)
Debug " " + "fsState: " + Str( \fsState)
Debug " " + "fsStyle: " + Str( \fsStyle)
Debug " " + "dwData: " + Str( \dwData)
Debug " " + "iString: " + Str( \iString)
EndWith
Next
Posted: Mon May 01, 2006 10:03 pm
by xgp
Thanks Trond!
Haven't tested it yet, but meanwhile, went searching a bit more and found this:
http://www.codeproject.com/tools/ShellTrayInfo.asp
Tested it, and at least the "get the number of buttons" worked.
But i think, this only works on XP, according to the web site.
Bye!
Posted: Tue May 02, 2006 12:43 pm
by Trond
Mine also gets the correct number of icons before it crashes

It is supposed to work on XP and Windows 2000.