4

I've basically copied the following code straight from the MSDN documentation:

#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "user32.lib")

int main()
{
   BOOL fResult;
   int aMouseInfo[3];       // array for mouse information

   // Get the current mouse speed. 

   fResult = SystemParametersInfo(
      SPI_GETMOUSE,   // get mouse information 
      0,              // not used 
      &aMouseInfo,    // holds mouse information
      0);             // not used 

   // Double it. 

   if( fResult )
   {
      aMouseInfo[2] =  1; // 2 * aMouseInfo[2]; 
      // 1 should be a very noticeable change: slowing the cursor way down
      // Change the mouse speed to the new value. 

      SystemParametersInfo(
         SPI_SETMOUSE,      // set mouse information
         0,                 // not used 
         aMouseInfo,        // mouse information 
         SPIF_SENDCHANGE);  // update win.ini 
   }
   return 0;
}

Yet when I run it, nothing seems to happen. The mouse speed should change, but it doesn't.

Windows Vista Home x32 (ouch) Dev-C++ Portable

Chris
  • 68
  • 1
  • 5
  • When I tested this, I output the value of `aMouseInfo [2]` every time while doubling it (your code says "= 1" instead of "*= 2"). Each time it ran, I saw the number double, which meant it was being saved throughout runs, but setting it both low and high didn't physically change the mouse speed for me. – chris Mar 24 '12 at 03:46
  • That's one thing that confuses me: there aren't any errors, and the member of the struct stays changed, but the actual mouse speed is unaffected. Meanwhile, calling SystemParametersInfo from AutoHotkey works just fine... – Chris May 05 '12 at 22:54

1 Answers1

2

Here , aMouseInfo[2] refers to Enhance Mouse Precision field. if aMouseInfo[2] is set to TRUE ( or assigned any no. other than 0 ), then Enhance Mouse Precision field is SET and if FALSE ( or assigned 0 ) then Enhance Mouse Precision field is UNSET .

For getting and setting the Mousespeed you can use SPI_GETMOUSESPEED and SPI_SETMOUSESPEED resp.

To use SPI_GETMOUSESPEED and SPI_SETMOUSESPEED , please refer to the post .

Community
  • 1
  • 1
Biraj Bora
  • 888
  • 2
  • 12
  • 25