directx mouse click simulation

2019-08-14 14:50发布

问题:

How can I simulate the mouse click in a directx application? mouse_event and PostMessage with WM_LBUTTONDOWN don't work...

so it must be something to do with the DirectInput

I haven't found out nothing useful with google, so you may be knowing the answer...

thanks in advance

//update

I wrote the text wrongly, what I want is to make the directx app believe that the mouse has just clicked, but without effectively using the mouse and without using SendInput or mouse_event, which need that the window must be focused

回答1:

Try AutoIt it is perfect for sending a click to a particular control. The

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )

command can do exactly what you want. The directx control will detect the click.



回答2:

If it is your own application, could you refactor out the click event into something like (in psuedocode):

void click(int x, int y)  {
     do_action();
}

or

void area_click(int x, int y) {
     do_action();
}

which is called by the real click handler.