用它可以找到你要的按钮,不过它不支持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.
[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.
解决方案 »
- delphi?
- 快来抢分啊:关于动态创建TcpClient控件的问题,高手们请进
- 一个简单的问题,但我不晓得如何做,请帮助
- Access的单表导入导出问题
- 请教各位一个内存释放的问题,多谢关注...
- ListView的ScrollBar问题-谢谢您的参与!
- 为什么我的问题总是没人回答呢?这次我再问问吧!!
- 我是学vc的,现在开始学delphi了,希望大家多多关照!先散点分!
- 如何在程序运行时检查表单,把某个字段中小于某个值的记录的另外一个字段值显示出来
- 怎样才知道准备打开的文件是否已经被其他程序打开了?怎样读取一个只读文件的内容呢?
- 高分请教,DBGrid问题
- 怎样insert 表1的当前记录到表2里?
比如说要找到一个窗体的某一个caption为button1的按钮。
可以这样取得句柄:
findwindowex(hand1,0,'tbutton','button1');
hand1为你要找的那个窗体的句柄!
我在找窗口的句柄的时候用了GETWINDOW的NEXTHWND的参数,现在用FINDWINDOW来查找按钮的句柄,如果查找出来的第一个按钮不是我要查找的,那么如何查找下一个按钮呢?
hbutton: hwnd;hbutton:=findwindowex(hparent,0,nil,'按钮的Caption');//hparent 是该按钮所在的父窗口的句柄;
一定要找到 hparent 才行的。如果按钮有快捷键一定要在 Caption 处加上 (&快捷键字母);
最后,用 sendmessage(hbutton,bm_click,0,0);就可以实现点击了。你一定要给分我哦!