CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2009
    Posts
    128

    [RESOLVED] getting the handles ?

    how can i get the handles of

    1) the start button on the task bar

    and

    2)the systemtray on the task bar

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: getting the handles ?

    You can use the Spy++ tool ( VisualCInstallFolder\Common7\Tools) to grab the window hierarchy from the desktop and then use FindWindowEx to navigate to the desired button/window.

    On my machine running XP, from the destop the hierarchy is as follows

    Code:
     
            Title      Class
    Root  NULL          #32769 (Desktop)
     L      NULL          Shell_Tray
       L    "start"        Button
     L      NULL          TrayNotifyWnd
       L    "11:02 AM"  TrayClockWClass
       L    NULL           SysPager
       L    NULL           Button
    Another way to approach this (and a more reliable way, imo) is to use Active Accessibility. AA gives you more control over accessing UI entities that may not be available using other windowing techniques (like FindWindow, EnumWindows, etc.)

  3. #3
    Join Date
    Nov 2009
    Posts
    128

    Re: getting the handles ?

    1)HWND hShellTrayWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

    2) HWND hStartButton = ::FindWindowEx(hShellTrayWnd,0,"Button","start");

    i got system traywindow handle .
    but start buttons handle.what wrong with 2 plz correct

    Another way to approach this (and a more reliable way, imo) is to use Active Accessibility
    what is Active Accessibility ?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: getting the handles ?

    Quote Originally Posted by dskp View Post
    1)HWND hShellTrayWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);

    2) HWND hStartButton = ::FindWindowEx(hShellTrayWnd,0,"Button","start");

    i got system traywindow handle .
    but start buttons handle.what wrong with 2 plz correct
    Code:
    HWND hShellTrayWnd = NULL, hStartBtn = NULL;
    
     
    if( NULL != ( hShellTrayWnd = ::FindWindowEx( NULL, NULL, _T("Shell_TrayWnd"), NULL ) ) )
    {
      hStartBtn = ::FindWindowEx( hShellTrayWnd, NULL, _T("Button"), _T("start") );
    }
     
    


    Again, this works on XP. For other operation systems like Vista and Win7, the hierarchy, class names and/or title names may change.

    Quote Originally Posted by dskp View Post
    what is Active Accessibility ?
    What is google?

  5. #5
    Join Date
    Nov 2009
    Posts
    128

    Re: getting the handles ?

    my question was wrong .
    i want popup menu's handle.sorry .

    Code:
             CWnd* m_Window = CWnd::FindWindow("Shell_TrayWnd","");
    	 
             HWND hStartbtn = (HWND)m_Window->GetTopWindow();
    
              //what should i do after this
    how to get start button popup menu handle ?

  6. #6
    Join Date
    Nov 2009
    Posts
    128

    Talking Re: getting the handles ?

    i got it .

    used
    Code:
     
    
          HWND hStartMenu = ::FindWindow(_T("DV2ControlHost"), NULL);

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

Featured