Results 1 to 15 of 15

Thread: Get the Hwnd's of TaskBar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    Unhappy 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

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    UK
    Posts
    417

    Re: Get the Hwnd's of TaskBar

    Get windows taskbar Hwnd

    VB Code:
    1. Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" _
    2. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3.  
    4. Private Sub Command1_Click()
    5. Dim TaskB As Long
    6.     TaskB = FindWindow("Shell_Traywnd", vbNullString)
    7.    
    8.     If (TaskB = 0) Then
    9.         MsgBox "Can't find Shell_Traywnd"
    10.     Else
    11.         MsgBox TaskB '' taskbar hwnd
    12.     End If
    13.    
    14. 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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    Unhappy 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

  4. #4
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    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:
    1. 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:
    1. Dim tWnd As Integer
    2. Dim bWnd As Integer
    3. tWnd = FindWindow("Shell_TrayWnd", vbNullString)
    4. bWnd = FindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    Red face 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:
    1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
    2. ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    4. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    5. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
    6. hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    7.  
    8. Private Const WM_USER = &H400
    9. Private Const TB_BUTTONCOUNT = (WM_USER + 24)
    10.  
    11. Private Sub Form_Load()
    12.  twnd = FindWindow("Shell_TrayWnd", vbNullString)
    13.  twnd = FindWindowEx(twnd, 0&, "ReBarWindow32", vbNullString)
    14.  twnd = FindWindowEx(twnd, 0&, "MsTaskSwWClass", vbNullString)
    15.  twnd = FindWindowEx(twnd, 0&, "ToolbarWindow32", vbNullString)
    16.  
    17.  MsgBox "Buttons : " & SendMessage(twnd, TB_BUTTONCOUNT, 0&, 0&)
    18. End Sub

    That is for another stuff, because is not related to the Task-Toolbar. Is related only to the Shell_TrayWnd

    VB Code:
    1. 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

  6. #6
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    Red face 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

  8. #8
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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?

  9. #9
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    Smile 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:
    1. Private Type POINTAPI
    2.     x As Long
    3.     y As Long
    4. End Type
    5.  
    6. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    7. Private Declare Function AccessibleObjectFromPoint Lib "oleacc" _
    8. (ByVal x As Long, ByVal y As Long, ppoleAcc As Object, pvarElement As Variant) As Long
    9.  
    10. Private Sub Timer1_Timer()
    11.  On Error Resume Next
    12.  
    13.  Dim p As POINTAPI
    14.  Dim objAccessible As Object
    15.  Dim v As Variant
    16.  Dim sName As String
    17.  
    18.  GetCursorPos p
    19.  
    20.  AccessibleObjectFromPoint p.x, p.y, objAccessible, v
    21.  
    22.  Label1 = objAccessible.accName(v)
    23. 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.

  11. #11
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    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.

  12. #12
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Get the Hwnd's of TaskBar

    Did you try using WindowFromAccessibleObject?
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type POINTAPI
    4.     x As Long
    5.     y As Long
    6. End Type
    7.  
    8. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    9. Private Declare Function AccessibleObjectFromPoint Lib "oleacc" ( _
    10.     ByVal x As Long, _
    11.     ByVal y As Long, _
    12.     ppoleAcc As Object, _
    13.     pvarElement As Variant _
    14. ) As Long
    15.  
    16. Private Declare Function WindowFromAccessibleObject Lib "oleacc" ( _
    17.     ByVal pacc As Long, _
    18.     phWnd As Long _
    19. ) As Long
    20.  
    21.  
    22. Private Sub Timer1_Timer()
    23.  
    24.  Dim p As POINTAPI
    25.  Dim objAccessible As Object
    26.  Dim v As Variant
    27.  Dim phWnd As Long
    28.  
    29.  GetCursorPos p
    30.  
    31.  AccessibleObjectFromPoint p.x, p.y, objAccessible, v
    32.  Label1 = objAccessible.accName(v)
    33.  
    34.  WindowFromAccessibleObject ObjPtr(objAccessible), phWnd
    35.  Label2 = Hex(phWnd)
    36.  
    37. End Sub

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    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

  14. #14
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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?

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Oct 2005
    Posts
    16

    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
  •  



Click Here to Expand Forum to Full Width