Simulate mouse clicks

Posted By: alibaba

Simulate mouse clicks - 04/30/16 07:58

How do I simulate mouse clicks in 3DGS?
I tried everything winAPI wise, it seems like Acknex has no event set for simulated mouse clicks.

Neither sys_message, nor SendMessage works. Also mouse_event doesn't work. PostMessage as well. I'm helpless.
Posted By: Ch40zzC0d3r

Re: Simulate mouse clicks - 04/30/16 10:17

No idea what you did, this works perfectly fine for me.
Code:
while(1)
{
	if(key_l)
	{
		mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, 0, 0, 0, 0);
		wait(1);
		mouse_event(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, 0, 0, 0, 0);
	}
	
	wait(1);
}

Posted By: alibaba

Re: Simulate mouse clicks - 04/30/16 10:23

Wow, I didn't know I had to use MOUSEEVENTF, but you're right, your code works!
Thank you very much!
Posted By: Ch40zzC0d3r

Re: Simulate mouse clicks - 04/30/16 10:27

MOUSEEVENTF is used so I dont have to get the current mouse pos.
The x and y coords will be relative to the cur mouse pos which means passing 0 wont change the mouse pos at all.

I guess you simply forgot to put a wait(1) between because this way the engine wont register any click but will stop any real mouse clicks from happening laugh
Posted By: alibaba

Re: Simulate mouse clicks - 04/30/16 10:35

You're right, it really was the wait(1) crazy
Posted By: MasterQ32

Re: Simulate mouse clicks - 05/07/16 08:21

alibaba, you can send clicks also with using the combined mouse-down, mouse-up events in mouse_event function. Also the wait(1) shouldn't be necessary.
Why do you want to simulate a mouse click?
Posted By: alibaba

Re: Simulate mouse clicks - 05/07/16 08:27

To click Panel Buttons using a Joystick. I set the mouse pos to the next button and simulate the mouse click in order to run the button event. Maybe it's also possible to make all buttons seperate panels but that would be too much rework of the code.
© 2024 lite-C Forums