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

前端 未结 12 1387
小蘑菇
小蘑菇 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:46

    Microsoft is now pushing Active Accessibility (MSAA) for UI Automation, (It has been renamed a number of times over the years) see

    • UI Automation and Microsoft Active Accessibility
    • Using UI Automation for Automated Testing
    • UI Automation Clients for Managed Code

    Sorry I don’t have any simple code to get you started. As “SendMessage()” does not seem to be working for you, I don’t know of another option apart from “UI Automation”

    I am assuming you have check with Spy++ (installed with MsDev) that you message are being send to the correct button etc – and that the button is a standard windows buttons. My first instant would say use “SendMessage()" or "PostMessage()” but given the numbers of answers about “SendMessage()” and the fact it is not working for you. I expect someone is going on…

提交回复
热议问题