This program is written
in Visual Basic 6, and uses the DirectInput segment of DirectX7 to retrieve
low-level information about mouse movement. DirectInput will return information
about mouse relative movement (amongst other things) before the screen cursor
bounding and cursor acceleration is applied by Windows. To this end, the mouse
can be used as a position input device. The program returns the X, Y coordinates
of the mouse relative to it's position at the time of program startup.
The program acts as a DDE service whereby other applications can query the values
of the data inside it's objects. Instructions for communicating with the program
can be found on the form when opened.
We can use Excel to demonstrate how this is done: start MouseDataDirect up, then in an Excel sheet, set a cell's formula as '=MouseDataDirect|DataForm!txtDX'. The value of the cell will change periodically as the mouse is moved. Communication appears slow in Excel, but other applications allow higher sampling rates.
DDE conversations can be made in LabVIEW using the DDE tools in 'LabVIEW 6/vi.lib/platform/dde.llb' and examples of use are in 'LabVIEW 6/Examples/comm/ddeexamp.llb'.
Download the code: MouseDataDirect.zip
Contributed by
Zac Mullett (August 2003)