`
includemain
  • 浏览: 32061 次
  • 性别: Icon_minigender_1
  • 来自: 嘉兴
社区版块
存档分类
最新评论

迭代窗口/模拟点击按钮

阅读更多
#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;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics