当鼠标移到某个应用程序窗口上的时候,
可以把窗口上的所有控件(例如Button,TextBox,CheckBox,ScrollBar以及菜单)的句柄、ID全都取出来。
判断出是什么控件,取出Caption、Text、Value等值,
并且接着可以模拟按钮和菜单的Click触发事件、文本框的KeyIn等等。
请指教。

解决方案 »

  1.   


      Platform SDK: Windows User Interface 
    EnumChildWindows
    The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE. BOOL EnumChildWindows(
      HWND hWndParent,         // handle to parent window
      WNDENUMPROC lpEnumFunc,  // callback function
      LPARAM lParam            // application-defined value
    );
    Parameters
    hWndParent 
    [in] Handle to the parent window whose child windows are to be enumerated. If this parameter is NULL, the parent window is the desktop window, and the function enumerates all top-level windows. 
    lpEnumFunc 
    [in] Pointer to an application-defined callback function. For more information, see EnumChildProc. 
    lParam 
    [in] Specifies an application-defined value to be passed to the callback function. 
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
    If a child window has created child windows of its own, EnumChildWindows enumerates those windows as well. A child window that is moved or repositioned in the Z order during the enumeration process will be properly enumerated. The function does not enumerate a child window that is destroyed before being enumerated or that is created during the enumeration process. Requirements 
      Windows NT/2000: Requires Windows NT 3.1 or later.
      Windows 95/98: Requires Windows 95 or later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.See Also
    Windows Overview, Window Functions, EnumChildProc, EnumThreadWindows, EnumWindows, GetWindow Built on Wednesday, February 09, 2000Requirements 
      Windows NT/2000: Requires Windows NT 3.1 or later.
      Windows 95/98: Requires Windows 95 or later.
      Header: Declared in Winuser.h; include Windows.h.
      Library: Use User32.lib.
    See Also
    Windows Overview, Window Functions, EnumChildProc, EnumThreadWindows, EnumWindows, GetWindow 
      

  2.   

    有好几种办法,楼上的是一个好法
    还有
    GetWindow
    The GetWindow function retrieves a handle to a window that has the specified relationship (Z order or owner) to the specified window. HWND GetWindow(
      HWND hWnd,  // handle to original window
      UINT uCmd   // relationship
    );
    Parameters
    hWnd 
    [in] Handle to a window. The window handle retrieved is relative to this window, based on the value of the uCmd parameter. 
    uCmd 
    [in] Specifies the relationship between the specified window and the window whose handle is to be retrieved. This parameter can be one of the following values. Value Meaning 
    GW_CHILD The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows. 
    GW_ENABLEDPOPUP Windows 2000: The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window.  
    GW_HWNDFIRST The retrieved handle identifies the window of the same type that is highest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is highest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is highest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is highest in the Z order. 
    GW_HWNDLAST The retrieved handle identifies the window of the same type that is lowest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is lowest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is lowest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is lowest in the Z order. 
    GW_HWNDNEXT The retrieved handle identifies the window below the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window below the specified window. If the specified window is a top-level window, the handle identifies the top-level window below the specified window. If the specified window is a child window, the handle identifies the sibling window below the specified window. 
    GW_HWNDPREV The retrieved handle identifies the window above the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window above the specified window. If the specified window is a top-level window, the handle identifies the top-level window above the specified window. If the specified window is a child window, the handle identifies the sibling window above the specified window. 
    GW_OWNER The retrieved handle identifies the specified window's owner window, if any. For more information, see Owned Windows.  
      

  3.   

    现在取菜单的句柄和内容是件很麻烦的事。
    有没有很好的例子给我发一份好吗?
    [email protected]