#include <iostream>
#include <fstream>
#include <math.h>
#include <cctype>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
//cout << "Hello world!" << endl;
HWND hwnd = FindWindow( 0, "文件窗口" );
//HWND hWnd2 = GetDlgItem( hwnd, 1001);
char* strs = new char[ 255 ];
HWND hWnd2 = ::FindWindowEx(hwnd,NULL,"Button",NULL);
while ( hWnd2 )
{
GetWindowText( hWnd2, strs, 255 );
cout << strs << endl;
/* if ( strcasecmp( strs, "确定" ) == 0 ) {
break;
}*/
hWnd2 = FindWindowEx( hwnd, hWnd2, "Button", NULL );
}
UINT nCtrlID = ::GetDlgCtrlID(hWnd2);
::PostMessage(hWnd2, WM_COMMAND, (WPARAM)(BN_CLICKED << 16 | nCtrlID), (LPARAM)hWnd2);
::PostMessage(hWnd2,WM_MOUSEMOVE, MK_LBUTTON, MAKELONG(0,0) );
::PostMessage(hWnd2,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(0,0));
::PostMessage(hWnd2,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(0,0));
return 0;
}
迭代窗口/模拟点击按钮
最新推荐文章于 2024-03-12 23:13:07 发布