-
Oct 10th, 2005, 10:33 PM
#1
Thread Starter
Junior Member
Get the Hwnd's of TaskBar
I can get the Title of the TaskBar windows (i mean the buttons that are in Start Bar) with Active Accessibility, but i want to get the Hwnd's of that buttons
In fact i need it when i move he mouse over it
I see some samples that uses the TB_GETBUTTON but still not understand and that samples are to Internet Explorer toolbar
Any help ?
Sorry about my bad english, i'm from Mexico
-
Oct 10th, 2005, 10:54 PM
#2
Hyperactive Member
Re: Get the Hwnd's of TaskBar
Get windows taskbar Hwnd
VB Code:
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim TaskB As Long
TaskB = FindWindow("Shell_Traywnd", vbNullString)
If (TaskB = 0) Then
MsgBox "Can't find Shell_Traywnd"
Else
MsgBox TaskB '' taskbar hwnd
End If
End Sub
Well that will get the hwnd of the widnows taskbar for you. to get the buttons you chould have a look at the class names with Spy++. then use FindWindowEx to get the hwnd of the child hwnds
As for knowning when your moveing over a button on the taskbar I am not 100% sure on how to do this. it may require some subclassing of some form. tho I might be wrong.
anyway that about much help I can give you. good luck.
When your dreams come true.
On error resume pulling hair out.
-
Oct 10th, 2005, 11:41 PM
#3
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
Well.. with that i only can get the Hwnd of the ToolBar and how many buttons have it with TB_BUTTONCOUNT. But i can't get the Hwnds yet
What i really need is get and identifier to know what button is from what window. I can get the Text with AccesibleObjects but 2 windows can have the same text, so is not good
Edit : I can get the Text when move the mouse with AccessibleObjects, but i need the Hwnd
-
Oct 11th, 2005, 01:51 AM
#4
Re: Get the Hwnd's of TaskBar
Here you go, add these snippets:
This is for VB.NET.
VB6, change integers to long.
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
VB Code:
Dim tWnd As Integer
Dim bWnd As Integer
tWnd = FindWindow("Shell_TrayWnd", vbNullString)
bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
-
Oct 11th, 2005, 09:52 AM
#5
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
With this i can get the number of buttons in the Task-Toolbar
In Win2k (here in Work) is not same than WinXP (in home). In fact, is different if you have the QuickIcons (is another Toolbar)
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_USER = &H400
Private Const TB_BUTTONCOUNT = (WM_USER + 24)
Private Sub Form_Load()
twnd = FindWindow("Shell_TrayWnd", vbNullString)
twnd = FindWindowEx(twnd, 0&, "ReBarWindow32", vbNullString)
twnd = FindWindowEx(twnd, 0&, "MsTaskSwWClass", vbNullString)
twnd = FindWindowEx(twnd, 0&, "ToolbarWindow32", vbNullString)
MsgBox "Buttons : " & SendMessage(twnd, TB_BUTTONCOUNT, 0&, 0&)
End Sub
That is for another stuff, because is not related to the Task-Toolbar. Is related only to the Shell_TrayWnd
VB Code:
bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
Please, if somebody wants to help then give some REAL samples
As i say, i can get the Task-Toolbar, the number of Buttons and the Text of every Button (with AA). I'm just want to get the Hwnd's or some identifier to i can know what button is for what window
Last edited by sunco; Oct 11th, 2005 at 09:53 AM.
Reason: some corrections on the text. too long strings
-
Oct 11th, 2005, 12:38 PM
#6
Re: Get the Hwnd's of TaskBar
The buttons in the taskbar don't have hwnds.
What exactly are you trying to do?
You can hook the taskbar to intercept messages sent to it to get when the mouse is over a button. Then Use TB_GETBUTTON or TB_GETBUTTONINFO.
Alternatively, you could set a WH_MOUSE_LL hook to monitor the position of the mouse at all times. Using this position you could try to calculate when the mouse is over the task bar. The advantage to this method is that you could do it all in VB.
-
Oct 11th, 2005, 12:55 PM
#7
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
What exactly are you trying to do?
Ok. I want to show a Screenshot of that Window when i move the mouse over the button. I see that in Windows Vista Beta 2
I can get a picture every X seconds. That picture is for every window, i mean, for every Hwnd. So, every Picture have the Hwnd in the Tag property
I have not problem with Pictures of every Window
When i move the mouse over a button, i need to know to what window it belongs and then can show the apropiate screenshot
With ActiveAccessibility i can get the Text of the buttons, but if two windows have the same Title then i can't know wich Window it belong
Just like this
http://www.winsupersite.com/images/showcase/5219_07.jpg
Again, thanks for all the help and sorry about my bad english
-
Oct 11th, 2005, 03:34 PM
#8
Re: Get the Hwnd's of TaskBar
I don't know what ActiveAccessibility is. Are you saying that you have no trouble telling which button the mouse is over with ActiveAccessibility?
Also, where do all these pictures come from? What does each button run?
Can you explain in more detail and show the code you are currently using?
-
Oct 11th, 2005, 03:37 PM
#9
Re: Get the Hwnd's of TaskBar
After studying the picture you posted a little more I think I know what you are trying to do.
Each button is a folder and you want to popup a thumbnail-sized picture of what that folder would look like if it were maximized. Correct?
Still don't know what ActiveAccessibility is so show me the code you are using now.
-
Oct 11th, 2005, 04:02 PM
#10
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
In my words, Accessibility hooks the hwnd's of your project. I learn that when i try to get a Conversation in MSN (not for hack, just for see if i can change some stuff) and see that the Hwnds are not there
I mean, with ActiveAccesibility you can see some stuff that are "hide" or is hard to get. In this case the Text on the Buttons. If you check Spy++ don't show the Buttons, just show the Classname of the Toolbar and some stuff like that
With this code you can get some stuff. Move the mouse over the buttons and you can get the Title of every one. You need a Reference to oleacc.dll
VB Code:
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function AccessibleObjectFromPoint Lib "oleacc" _
(ByVal x As Long, ByVal y As Long, ppoleAcc As Object, pvarElement As Variant) As Long
Private Sub Timer1_Timer()
On Error Resume Next
Dim p As POINTAPI
Dim objAccessible As Object
Dim v As Variant
Dim sName As String
GetCursorPos p
AccessibleObjectFromPoint p.x, p.y, objAccessible, v
Label1 = objAccessible.accName(v)
End Sub
Whitout moving the mouse exists another kind of Apis, like AccChildren (can google it)
More info can get here : http://msdn.microsoft.com/library/de...actvaccess.asp
Well i have no problem with that and have no problem with screenshots, i only want to know the Hwnd or some Unique ID
Edit : With this file you can see more http://www.microsoft.com/downloads/i...Explorer32.exe just click on "Select with mouse" and drag the cursor over the toolbar or another app
Last edited by sunco; Oct 11th, 2005 at 04:08 PM.
-
Oct 11th, 2005, 11:05 PM
#11
Re: Get the Hwnd's of TaskBar
Please, if somebody wants to help then give some REAL samples
Sorry, but it was not clear, it sounded like you wanted the hwnd for just the start button.
You are better than I... you know at least three languages.
-
Oct 12th, 2005, 08:29 AM
#12
Re: Get the Hwnd's of TaskBar
Did you try using WindowFromAccessibleObject?
VB Code:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function AccessibleObjectFromPoint Lib "oleacc" ( _
ByVal x As Long, _
ByVal y As Long, _
ppoleAcc As Object, _
pvarElement As Variant _
) As Long
Private Declare Function WindowFromAccessibleObject Lib "oleacc" ( _
ByVal pacc As Long, _
phWnd As Long _
) As Long
Private Sub Timer1_Timer()
Dim p As POINTAPI
Dim objAccessible As Object
Dim v As Variant
Dim phWnd As Long
GetCursorPos p
AccessibleObjectFromPoint p.x, p.y, objAccessible, v
Label1 = objAccessible.accName(v)
WindowFromAccessibleObject ObjPtr(objAccessible), phWnd
Label2 = Hex(phWnd)
End Sub
-
Oct 12th, 2005, 09:23 AM
#13
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
Did you check that code ? Is the same, it only get the text, the phWnd not change when i move the mouse over the buttons
Maybe i need to hook the toolbar and see what position is the button of the active window or if the button is pressed and some mathematic stuff
-
Oct 12th, 2005, 09:28 AM
#14
Re: Get the Hwnd's of TaskBar
That tells me that the buttons don't have a handle as I mentioned before.
Let's look at this in a different way. What specifically were you going to do with the handle once you obtained it?
-
Oct 12th, 2005, 09:33 AM
#15
Thread Starter
Junior Member
Re: Get the Hwnd's of TaskBar
Well i have picture(N), every picture have in their Tag Propertie the Hwnd of the window that it belongs. I can add that picture to a form and appear ontop of the button
If a Windows is closed, i remove the hwnd from a listbox and the picture(X) that contains the hwnd in the Tag
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|