BBC BASIC for Windows
Programming >> Communication and Input/Output >> Control of Mouse & Keyboard
http://bb4w.conforums.com/index.cgi?board=communication&action=display&num=1407998961

Control of Mouse & Keyboard
Post by Kipper on Aug 14th, 2014, 06:49am

I am working on a project to control Mouse and Keyboard inputs (including Mouse X% & Y%) for people with disability who cannot use their hands. Thus I would like to be able to gain input focus for mouse and keyboard in other programmes, such as MS Word.

What I want to do then is to send a Mouse Click to the buffer so that the PC interprets it as if coming from Mouse when in fact it comes from BBC Basic. I would use the "MOUSE TO" command to locate the pointer position. I want to then also be able to insert text (if needed) at the point of Mouse input focus, again with the PC interpreting input as from the Keyboard rather than from a BBC basic.

I already have some code that controls MOUSE X% and Y% by eye movements but it is the I/O operations that I am struggling with.

Any suggestions welcome!

thanks

Kipper
Re: Control of Mouse & Keyboard
Post by rtr on Aug 14th, 2014, 09:33am

on Aug 14th, 2014, 06:49am, Kipper wrote:
What I want to do then is to send a Mouse Click to the buffer so that the PC interprets it as if coming from Mouse when in fact it comes from BBC Basic.

You should be able to adapt the code for faking keyboard input so that it fakes mouse input instead:

http://bb4w.wikispaces.com/Faking+keyboard+input

You will need to change the SYS "keybd_event" call to SYS "mouse_event" and modify the parameters to correspond with what Windows needs as documented here:

http://msdn.microsoft.com/en-gb/library/windows/desktop/ms646260.aspx

Alternatively you can use the SendInput API:

http://msdn.microsoft.com/en-gb/library/windows/desktop/ms646310.aspx

Richard.