PDA

View Full Version : how to move mouse and press button



splash
29th July 2009, 11:39 PM
hi, when pressing button 1 i would like to move the mouse to a place in the screen and later press left button. The first part is easy:
if (js1.b1) then
screenx=100;
screeny=100;
endif

but, what's the sintax to send LCLICK in the CMS script? Any other method?

Thanks in advance.

Bob Church
30th July 2009, 01:41 AM
Hi Splash,

LCLICK is hard to use since it gets put into the character queue. I'd use the script to click a CMS button, then let the CMS button generate a DX Mode click. It acts like hardware then, it's not tied to the character queue, and it's much more reliable.

You could use a timer to generate the pulse:


script
timer( PERIOD, d1, 1 ) = js1.b1;
cms.b1 = d1
endScript

You could also put it in a SEQUENCE with a DELAY to hold it on for one scan:


script
sequence
wait( js1.b1 );
cms.b1 = TRUE;
delay( 1 );
cms.b1 = FALSE;
endSequence
endScript

Button 1 on the CMS Controls tab would get the click so up in the GUI you'd need to assign it in DX Mode to "Mouse" and "Button 1". I'm not sure how you'd actually need to integrate it into your script, but that would generate the left-click.

Does that help?

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

splash
30th July 2009, 08:48 AM
Thank you very much, I'll try that tonight definitely. I'm pretty sure that your solutions are the best ones.

After posting my message, I tested several things and one that worked was putting LCLICK in the press box in Normal Action in Button 1 and apparently worked. The behavior of the Control Manager, is executing the script first and after that execute the action?

Bob Church
30th July 2009, 10:06 AM
Hi splash,

LCLICK puts a dummy character in the queue with any other characters that may be pending and clicks the mouse button when it's character comes out of the queue (they come out controlled by the scan time). A problem occurs if you send a lot of characters (any characters, actually) in each scan since it can't start the next scan until the queue is empty. The script does actually execute first, it shouldn't be something you normally have to think about, though. The script feeds the map, the map feeds the queue.

If you end up with a lot of characters in the queue on each scan, the LCLICK may be at the end of the queue and it's delayed while it's character moves through the queue. 100 characters can take 10 seconds or more to send, so the delay can be considerable. It can be especially bad with the mouse buttons since the LCLICK may not happen before the mouse itself is moved, the click doesn't come where you think it does. That can't happen if you use the DX emulation (Mouse and Button 1) since they don't get queued.

Anyway, it's just more susceptible to problems than the DX emulation. If it works in any particular map, there's no reason not to use it.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

splash
2nd August 2009, 01:41 PM
Hi again,

I tried your scripts and sorry but don't know how integrated it into my script. I'm using Jane's F-15 and would like to press MFD buttons with single joystick presses (game doesn't allows you to map MFD buttons to keys like Falcon). My idea is:

- when pressing js1.b1, move mouse to SCREENX=95 and SCREENY=468 and press left mouse button;
- when pressing js1.b1 and shift button (js2.b2), move mouse to SCREENX=120 and SCREENY=468 and press left mouse button.

My current script is something like this:

script

timer( PERIOD, d1, 1 ) = js1.b1;
SCREENX=95;
SCREENY=468;
cms.b1 = d1;

timer( PERIOD, d2, 1 ) = js1.b1 and js2.b2; // js2.b2 is my shift button
SCREENX=120;
SCREENY=468;
cms.b3 = d1 and js2.b2;

endScript

In the GUI I have Button 1 on the CMS Controls assigned in DX Mode to "Mouse" and "Button 1" in normal and shift actions.

Thanks again!