Nov 302007
 

The GetMouseMovePointsEx function retrieves a history of up to 64 previous coordinates of the mouse or pen.

Here is a demo that replays our mouse movements…

void ReplayMouseMovements()
{
   // Current cursor position
   POINT ptCurrentPoint = { 0 };
   GetCursorPos( &ptCurrentPoint );

   // Record marker, mouse co-ordinates prior(and including) to this point is returned in
   // the recorded array of points
   MOUSEMOVEPOINT mmpSamplePoint = { 0 };
   mmpSamplePoint.x = ptCurrentPoint.x;
   mmpSamplePoint.y = ptCurrentPoint.y;

   // Count of records expected, MSDN says max points returned will be 64
   // Anything greater than 64 results in error, API returns -1
   const DWORD dwMaxPoints = 64;

   // On return from function will hold last recorded mouse movements
   MOUSEMOVEPOINT mmpRecordedMovements[dwMaxPoints] = { 0 };
   const DWORD dwMode = GMMP_USE_DISPLAY_POINTS;

   // Get all points prior to sample point
   const int nPtCount = GetMouseMovePointsEx( sizeof( mmpSamplePoint ),
					&mmpSamplePoint,
					mmpRecordedMovements,
					dwMaxPoints ,
					dwMode ) ;

   // Loop through and animate
   for (int nIndex = 0; nIndex < nPtCount; nIndex++)
   {
      SetCursorPos( mmpRecordedMovements[nIndex].x, mmpRecordedMovements[nIndex].y );
      Sleep( 80 );
   }
}// End ReplayMouseMovements
Share

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>