#define UNICODE
#include <windows.h>

int main(int argc, char **argv)
{
    int speed1 = 0, speed2 = 0, speed = 0;
    printf("Set Mouse Speed by Maverick\n");
    
    SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0);
    printf("Current speed: %2d\n", speed);
    
    if (argc == 1) return 0;
    if (argc >= 2) sscanf(argv[1], "%d", &speed1);
    if (argc >= 3) sscanf(argv[2], "%d", &speed2);
    
    if (argc == 2) 
    { // set speed to fixed value
      speed = speed1;
  } 
  else if (argc == 3)
  { // alternate between two speed, otherwise speed1 will be used
    if (speed == speed1 || speed == speed2) speed = speed1 + speed2 - speed;
    else speed = speed1;
  }

  SystemParametersInfo(SPI_SETMOUSESPEED, 0, speed, 0);
    SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0);
    printf("New speed:     %2d\n", speed);
    return 0;
}