1

To put make it simple:

I have 2 emulators to which I'm simulating click on using SendMessage()


The emulator that I can dispatch this to is Nox

The window hierarchy and the window handle I'm passing the message to:

Window hierarchy

It works just as it's intended to do (Listening to the message using spy++) Nox

And the code:

SendMessage(NoxPlayer, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(width, height));
SendMessage(NoxPlayer, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(width, height));
SendMessage(NoxPlayer, WM_MOUSEMOVE, 0, MAKELPARAM(width, height));

I added the WM_MOUSEMOVE at the end because the noxplayer thinks I'm holding down L_Mouse click without it.


Now my problem lies here... I have another emulator called "MEmu player"

The window hierarchy and the window handle I'm passing the message to:

MEmu hierarchy

But when passing the same code as before:

SendMessage(MEmu, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(width, height));
SendMessage(MEmu, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(width, height));
SendMessage(MEmu, WM_MOUSEMOVE, 0, MAKELPARAM(width, height));

I get no simulated click on the application. I tried listening to any messages I'm passing but found none when going over all the visible windows using spy++.


Then I tried listening to how a normal mouse click would look like as messages using spy++ and got this:

MEmu

For reference, this is what the same click without simulation would look like on the Nox Player:

Nox player message


Am I using the wrong code to send the simulated mouse click or am I passing this to the wrong window?

  • 1
    From what I remember, you should not be attempting to simulate mouseclicks using WM_LBUTTONDOWN, WM_LBUTTONUP, etc. Those messages are produced by the Windows OS for your app to process, not for you to try and fake. The function that is usually used is (from what I remember, `SendInput` or similar). – PaulMcKenzie Apr 25 '18 at 18:34
  • @PaulMcKenzie I just saw this: https://stackoverflow.com/a/12363393/7346067 I managed to get the code to make my mouse right click but it doesn't move my mouse, It just does a right click. Also from what I read, it says that it will move my mouse pointer over the screen? I don't want that to happen though –  Apr 25 '18 at 18:45

1 Answers1

0

Ok so...

Managed to fix the problem I was having by doing 1 simple thing.

running my program with administrator rights

Since I'm using Microsoft Visual Studio to do all the programming, I just had to launch Visual Studio in administrator mode.

Fixed the problem while still keeping the original SendMessage() method of mouse click simulation