应该可以 ,使用spy++看下 那 个 窗口里所有的 句柄。。(spy++可以 查看所有当前窗口的 窗口类 的 名称,正好是 FindWindow()的第一参数 );
通过FindWindow()和FindWindowEx(),找到控件们的上一级窗口句柄,然后看 使用WindowFromPoint()(或者它的兄弟函数们如ChildWindowFromPointEx),能不能返回一个 正确的 窗口 句柄。。如果WindowFromPoint在非本程序中使用会失败的话,
可以使用GetFocus() 但 这个函数只能在本程序内,但使用AttachThreadInput()可以让它能获得其他程序的键盘焦点(我不知道是否可以等同为焦点),
这样就肯定能获得那个控件的句柄了。。
这里有篇实现程序键盘输入的文章,希望能给你点帮助。
http://www.35dx.com/html/otherTec/8/otherTec8699.html
应该能解决你的问题了。不知道这个分能给不?  如果还有什么疑问 可以留个邮箱。 有分一切好说。。

解决方案 »

  1.   

    一个办法, SetWindowsHookEx(WH_GETMESSAGE...) 勾住目标进程UI线程的WM_SETFOCUS消息
      

  2.   

    节应该可以   ,使用spy++看下   那   个   窗口里所有的   句柄。。(spy++可以   查看所有当前窗口的   窗口类   的   名称,正好是   FindWindow()的第一参数   ); 
    通过FindWindow()和FindWindowEx(),找到控件们的上一级窗口句柄,然后看   使用WindowFromPoint()(或者它的兄弟函数们如ChildWindowFromPointEx),能不能返回一个   正确的   窗口   句柄。。如果WindowFromPoint在非本程序中使用会失败的话, 
    可以使用GetFocus()   但   这个函数只能在本程序内,但使用AttachThreadInput()可以让它能获得其他程序的键盘焦点(我不知道是否可以等同为焦点), 
    这样就肯定能获得那个控件的句柄了。。 
    这里有篇实现程序键盘输入的文章,希望能给你点帮助。 
    http://www.35dx.com/html/otherTec/8/otherTec8699.html 
    应该能解决你的问题了。 
      

  3.   

    可以
    注入之后,调用 getactivewindow
      

  4.   

    GetWindowThreadProcessId、GetGUIThreadInfo
      

  5.   

    由于工作实际需要写了这个获取鼠标点窗口句柄方法的代码,给大家分享一下。/* The GetCursorPos function retrieves the cursor“‘s position, in screen coordinates. */BOOL GetCursorPos(LPPOINT &point);/* The WindowFromPoint function retrieves a handle to the window that contains the specified point. */HWND WindowFromPoint(POINT point);/*Thefunction retrieves a handle to a window that has the specified relationship ( or owner) to the specified window. */HWND GetWindow(HWND hWnd,UINT uCmd //通过把uCmd代码设置为GW_HWNDNEXT来获取兄弟窗口的句柄);