Programmatically press a button on another application (C, Windows)

前端 未结 12 1493
小蘑菇
小蘑菇 2021-01-30 14:47

I\'m trying to use the following code to press a button on my other application:

HWND ButtonHandle;
if( (wnd = FindWindow(0, \"Do you want to save?\")) )
{   
           


        
12条回答
  •  野性不改
    2021-01-30 15:32

    You can use sendkeys (as tr3 said) to send mouse clicks, which is different than using SendMessage. It is also less direct and more hack-ish, but is useful for automation (in VBS).

    Also, just a guess but the problem could be that your message handling is broken somewhere by not calling the base class member. Example:

    void CMyClass::OnMessageY(CWnd *cwnd)
    {
        CBaseClass::OnMessageY(cwnd);
        //... my code
    }
    

提交回复
热议问题