Archive

Posts Tagged ‘Mouse’

Set/Get mouse double click time

  1. To set double click time use SetDoubleClickTime
    • Set time to zero to switch to default time of 500 milliseconds
      E.g.

      // If call succeeds return value is non zero
      VERIFY( SetDoubleClickTime( 200 )); // Set double click time to 200 milliseconds
  2. To get double click time use GetDoubleClickTime
    • Returns double click time in milliseconds
      E.g.

      const UINT uDblClkTime = GetDoubleClickTime();
Advertisements

How to get mouse movement history?

November 30, 2007 Leave a comment

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[/sourcecode]

%d bloggers like this: