Thread: Changing mouse speed.

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    29

    Changing mouse speed.

    Hi, for a CAD type program im writing i need to change the mouse speed in different design mode (the sensetivity is too high for the right precision) and i cant find the right function, ive tried SPI_SETMOUSESPEED with the systemparametersinfo function, but to no avail. any ideas?

    Thanks,
    Jeromy

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Can you show us in your code where you tried to use the SPI_SETMOUSESPEED? This is right off of MSDN
    Quote Originally Posted by MSDN
    Code:
    #include <windows.h>
    #include <stdio.h>
    #pragma comment(lib, "user32.lib")
    
    void 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] = 2 * aMouseInfo[2]; 
     
          // 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 
       }
    }
    NOTE:Yes, they used void main(). Don't do that.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Registered User
    Join Date
    May 2011
    Posts
    29
    the code i was testing (with printout for checking) was
    Code:
    BOOL result = SystemParametersInfo(SPI_SETMOUSESPEED, 0, (void*)value, 0);
     if(result)
     printf("\nSuccess\n");
     else
     printf("\nFailure\n");
    and the compile log says SPI_SETMOUSESPEED undefined.

  4. #4
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Well, you can use the code off the MSDN link to do this, or if you really want to do it your way (Mind you I think WinXP is the only OS where you can set mouse speed this way, could be wrong) you could try to do this:

    Inside stdafx.h add:
    #define WINVER 0x0500
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Speed of pointers vs. speed of arrays/structs
    By Kempelen in forum C Programming
    Replies: 32
    Last Post: 06-27-2008, 10:16 AM
  2. Mouse pointer speed
    By geek@02 in forum Windows Programming
    Replies: 2
    Last Post: 11-26-2006, 10:31 AM
  3. Changing mouse pointer?
    By Matte in forum Windows Programming
    Replies: 9
    Last Post: 11-25-2004, 02:05 PM
  4. changing mouse pointer in c
    By MMM in forum Windows Programming
    Replies: 3
    Last Post: 05-11-2003, 08:28 PM
  5. changing mouse cursor
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 12-25-2001, 09:39 PM