控制其他应用软件

#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])

{

    char haha[200];

    HWND hwnd = ::FindWindow(NULL,"fortest");

    //::PostMessage(hwnd,WM_COMMAND,0x1B,0);

    if(hwnd != NULL)

    {

        //::GetDlgItemText(hwnd,0x3E8,haha,200);

        //printf("%s\n",haha);

        HWND editHwnd = ::GetDlgItem(hwnd,0x3E8);

        if(editHwnd != NULL)

        {    

            //::GetWindowText(editHwnd,haha,200);

            SendMessage(editHwnd, WM_GETTEXT, 80, (LPARAM)haha);

            printf("%s\n",haha);

        }

        else

            printf("ERROR!\n");



    }

    else

        printf("error\n");

    system("pause");

    return 0;

}

时间不多,把可用的代码贴上就可以。

postmessage那句话相当于发送一个菜单命令。

    ::Sleep(50);

    HWND hwndDialog = ::FindWindow(NULL,"Dialog");

    if(hwndDialog != NULL)

    {

        HWND editHwnd = ::GetDlgItem(hwndDialog,0x3E8);

        SendMessage(editHwnd,WM_SETTEXT,80,(LPARAM)haha);

        ::Sleep(50);

        HWND okHwnd = ::GetDlgItem(hwndDialog,0x01);

        PostMessage(okHwnd,BM_CLICK,0,0);

    }

你可能感兴趣的:(软件)