-1

What is the best way to handle mouse speed changes in a WPF application?

EDIT for more context:

I am developing a kiosk application that will run in Windows 10. It has it's own mouse speed control settings page, and a default speed that is significantly slower than normal. The programmer before me made the application set the pointer speed to the kiosk application default when the pointer enters the application bounds, and check if the pointer is out of bounds to revert the speed.

So the problem my team and I have is during development. The system mouse speed stays set to the kiosk application speed if it hits a break-point in visual studio. In production, this situation shouldn't come up because the user won't be able to leave the application. That's why I am having a hard time trying to figure out a better way of changing the mouse speed.

This question asked for something similar but isn't what I'm looking for.

Adam G.
  • 176
  • 9
  • 1
    Mouse Speed is and will be a Windows thing. Unless you start parsing raw Mouse Input, but that might become overly complex. | Personally this whole idea smells like a terrible idea. If I am using your programm, one of the last things I would want is it *randomly changing my mouse speed*. I want that about as much as it randomly mapping letters do different letters. – Christopher Nov 07 '19 at 21:08
  • Your only option is to change the system mouse speed, but I have to agree with @Christopher -- *why* do you want to do this? You should never globally mess with the user's input settings without their permission; it makes for a bad experience with your program. – Herohtar Nov 07 '19 at 21:10

1 Answers1

1

you answered your question already.
set your system mouse speed on form enter, and reset it on form leave.
reset it on Application close.

Store the original mouse speed in some static variable.

take a look at this thread: Dynamically changing Mouse speed

you can catch all unhandled exceptions:

// UI exceptions
Application.ThreadException += HandleErrorUI;

// Set the unhandled exception mode to force all Windows Forms errors
// to go through our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

// Add the event handler for handling non-UI thread exceptions to the event. 
AppDomain.CurrentDomain.UnhandledException += HandleError;
// handle all task exceptions
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;

Then if any unhandled error appears you reset your mouse cursor speed.

Charles
  • 2,721
  • 1
  • 9
  • 15