Detecting the Desktop / Taskbar
Moderators: JRL, Dorian (MJT support)
Detecting the Desktop / Taskbar
v12 (Windows XP sp3)
Hello,
Need a way to detect the Taskbar. To be more specific, the entire bar at the bottom of the screen. I can use
>GetWindowHandle>Program Manager,res
to get the handle for the program manager, but what can I use to get the handle for the Taskbar? I can get the handle of the taskbar by writing a program that on left click or some other trigger it displays the handle.
But what escapes me is what is the name of the taskbar?
To try to resolve this I tried....
GetWindowNames>196662,title,cl (the current handle of the Taskbar)
mdl>%title% %cl%
And it comes back with " Shell_TrayWnd"
I did this to show that it has a space in the name.
But then I tried....
>GetWindowHandle> Shell_TrayWnd,out
Edit - That's because it's not showing a NAME, but rather the CLASS. oops. But I learned.
But it just comes back with %out% (no result) Same "no result" without the space.
If knowing what I am doing helps, I am playing around with writing a hide window program. Using some of the scripts that JRL and others have provided in this forum. Why? Well..... because I can (Thanks to some of you). And I get some practice and experience with new ideas.
Any ideas?
Thanks.
Hello,
Need a way to detect the Taskbar. To be more specific, the entire bar at the bottom of the screen. I can use
>GetWindowHandle>Program Manager,res
to get the handle for the program manager, but what can I use to get the handle for the Taskbar? I can get the handle of the taskbar by writing a program that on left click or some other trigger it displays the handle.
But what escapes me is what is the name of the taskbar?
To try to resolve this I tried....
GetWindowNames>196662,title,cl (the current handle of the Taskbar)
mdl>%title% %cl%
And it comes back with " Shell_TrayWnd"
I did this to show that it has a space in the name.
But then I tried....
>GetWindowHandle> Shell_TrayWnd,out
Edit - That's because it's not showing a NAME, but rather the CLASS. oops. But I learned.
But it just comes back with %out% (no result) Same "no result" without the space.
If knowing what I am doing helps, I am playing around with writing a hide window program. Using some of the scripts that JRL and others have provided in this forum. Why? Well..... because I can (Thanks to some of you). And I get some practice and experience with new ideas.
Any ideas?
Thanks.
Last edited by PepsiHog on Tue Feb 01, 2011 6:20 am, edited 1 time in total.
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
Try this:
Edit - Added code in case the desired class name is the first handle encountered. Sorry I missed that possibility on the first posting.
Fixed to work with Win 7 and hopefully beyond.
Edit - Added code in case the desired class name is the first handle encountered. Sorry I missed that possibility on the first posting.
Fixed to work with Win 7 and hopefully beyond.
Code: Select all
Let>kk=1
LibFunc>user32,GetDesktopWindow,hwnd
LibFunc>user32,GetWindow,GWres,hwnd,5
GetWindowNames>GWres,title,class
If>class=Shell_TrayWnd,Done
Let>Window_%kk%=%GWres%
Repeat>GWres
Add>kk,1
LibFunc>user32,GetWindow,GWres,%GWres%,2
Let>Window_%kk%=%GWres%
GetWindowNames>GWres,title,class
If>class=Shell_TrayWnd,Done
Until>GWres=0
Label>Done
Let>hwnd=Window_%kk%
MDL>%CLASS% handle = %hwnd%
Last edited by JRL on Mon Jan 31, 2011 10:17 pm, edited 1 time in total.
Previous post
Thanks, JRL.
Hey,
So I studied this script. Will you let me know if I got it right, please?
From looking at the system windows in MS, it seems that 65556 is the top of all windows open. The beginning of ALL windows.
And then you simply cycle through them until you find the name that
the command GetWindowNames gave you for the taskbar.
And LibFunc provides the window handle.
How'd I do?
The only thing I have no idea about is... What is the parm 5?
Thanks again.
Edit - I realize now that the space in the result was the NAME(or lack of) and what I saw was the class. oops.
Hey,
So I studied this script. Will you let me know if I got it right, please?
From looking at the system windows in MS, it seems that 65556 is the top of all windows open. The beginning of ALL windows.
And then you simply cycle through them until you find the name that
the command GetWindowNames gave you for the taskbar.
And LibFunc provides the window handle.
How'd I do?
The only thing I have no idea about is... What is the parm 5?
Thanks again.
Edit - I realize now that the space in the result was the NAME(or lack of) and what I saw was the class. oops.
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
Perfect.How'd I do?
Microsoft explains it better than I could.What is the parm 5?
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Thanks
Thanks JRL!
I just added that link to my favorites.
And ofcourse, Thanks for the assist.
I just added that link to my favorites.
And ofcourse, Thanks for the assist.

Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
I can't get JRL's code to work in Windows 7. So this is what I came up with.
Taskbar must be located either at the bottom or top but it can be modified if the taskbar is located on the left or right side of the screen.
Taskbar must be located either at the bottom or top but it can be modified if the taskbar is located on the left or right side of the screen.
Code: Select all
GetScreenRes>ScreenWidth,ScreenHeight
Let>WIN_USEHANDLE=1
GetWindowHandle>User Promoted Notification Area,handle
Repeat>TaskbarWidth
Sub>handle,1
GetWindowSize>%handle%,TaskbarWidth,TaskbarHeight
Until>TaskbarWidth,ScreenWidth
Let>WIN_USEHANDLE=0
mdl>Taskbar Width: %TaskbarWidth%%CRLF%Taskbar Height: %TaskbarHeight%
Rain,
Thanks for the heads up. I recently purchased a Win 7 computer but I haven't done anything with it yet. I'll see if I can get it fired up before the end of summer
then perhaps figure out what is wrong with the previously posted code when using Win 7. I know while reading On the MSDN site about API stuff they often mention Win 7 changes. Maybe they reworked the GetWindow function or maybe they renamed the task bar icon class.
In any case. Thank you for your post. I look forward to trying it.
Thanks for the heads up. I recently purchased a Win 7 computer but I haven't done anything with it yet. I'll see if I can get it fired up before the end of summer

In any case. Thank you for your post. I look forward to trying it.
You're welcome JRL. I'm glad I was able to figure out a workaround.
I think you will like Windows 7. I'm still a huge XP Pro fan but I'm glad I finally made the switch to Windows 7 Ultimate. The speed is awesome and large APPs load in an instant on my system, the same APPs took roughly 30-40 seconds to load in XP Pro.
I think you will like Windows 7. I'm still a huge XP Pro fan but I'm glad I finally made the switch to Windows 7 Ultimate. The speed is awesome and large APPs load in an instant on my system, the same APPs took roughly 30-40 seconds to load in XP Pro.
There was a problem with my original example. This one should correct it.
Code: Select all
GetScreenRes>ScreenWidth,ScreenHeight
Let>WIN_USEHANDLE=1
GetWindowHandle>User Promoted Notification Area,handle
Add>handle,500
Repeat>TaskbarWidth
Sub>handle,1
GetWindowSize>%handle%,TaskbarWidth,TaskbarHeight
Until>TaskbarWidth,ScreenWidth
Let>WIN_USEHANDLE=0
mdl>Taskbar Width: %TaskbarWidth%%CRLF%Taskbar Height: %TaskbarHeight%