用它可以找到你要的按钮,不过它不支持NT的,你试试看吧
[Now Supported on Windows NT]The FindWindowEx function retrieves the handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the given child window.HWND FindWindowEx(    HWND hwndParent, // handle to parent window
    HWND hwndChildAfter, // handle to a child window 
    LPCTSTR lpszClass, // pointer to class name
    LPCTSTR lpszWindow // pointer to window name
   );
 ParametershwndParentIdentifies the parent window whose child windows are to be searched. 
If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop. hwndChildAfterIdentifies a child window. The search begins with the next child window in the Z order. hwndChildAfter must be a direct child window of hwndParent, not just a descendant window.
If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level windows.lpszClassPoints to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpszClass; the high-order word must be zero. lpszWindowPoints to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match.  Return ValuesIf the function succeeds, the return value is the handle to the window that has the specified class and window names.
If the function fails, the return value is NULL. To get extended error information, call GetLastError. 

解决方案 »

  1.   

    用findwindowex函数吧!
    比如说要找到一个窗体的某一个caption为button1的按钮。
    可以这样取得句柄:
    findwindowex(hand1,0,'tbutton','button1');
    hand1为你要找的那个窗体的句柄!
      

  2.   

    能不能给个源程序,还有就是按钮的类是什么?你的这个我怎么看象是DELPHI 上面的WINSDK的帮助。?
      

  3.   

    能不能给个源程序,还有就是按钮的类是什么?你的这个我怎么看象是DELPHI 上面的WINSDK的帮助。?
      

  4.   

    用findwindowex,findwindowex(hwnd,0,'tbutton','button1');hwnd是你要观察的窗口的句柄
      

  5.   

    控件都有Handle, 编程时直接用Button1.Handle可以得到按钮的Handle
      

  6.   

    我是要看别的程序的句柄,比如说,我在离开电脑的时候,如果别人关闭我的WORD,我的WORD会给出提示是否保存,我可以用程序找到按钮的句柄,然后自动的按下去“是”的按钮。让WORD可以自动保存我的文章。我现在的问题就是如何去找到这个按钮的句柄,然后如何向这个按钮去发送命令。
      

  7.   

    我在用findwindowex的过程中,如果有几个按钮,我应该用哪个函数来处理?
    我在找窗口的句柄的时候用了GETWINDOW的NEXTHWND的参数,现在用FINDWINDOW来查找按钮的句柄,如果查找出来的第一个按钮不是我要查找的,那么如何查找下一个按钮呢?
      

  8.   

    不是啊,肯定找得到的,我已经成功了啊
    hbutton: hwnd;hbutton:=findwindowex(hparent,0,nil,'按钮的Caption');//hparent 是该按钮所在的父窗口的句柄;
    一定要找到 hparent 才行的。如果按钮有快捷键一定要在 Caption 处加上 (&快捷键字母);
    最后,用 sendmessage(hbutton,bm_click,0,0);就可以实现点击了。你一定要给分我哦!
      

  9.   

    顺便问一句,QQ的窗口句柄哪位有好方法可以找到呢,它的‘caption’好象是一个随机变化的字符串。