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

前端 未结 12 1499
小蘑菇
小蘑菇 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条回答
  •  萌比男神i
    2021-01-30 15:44

    1. Are you sure that "SaveButton" class name is valid? Do you get the button handle?
    2. Try to send messages to ButtonHandle window (directly to the button).

    Update: I believe this should work,

    SendMessage(ButtonHandle, BM_CLICK, 0, 0);
    

提交回复
热议问题