Author Topic: Alter mouse movement speed when input key is held  (Read 3623 times)

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Alter mouse movement speed when input key is held
« on: August 12, 2020, 12:42:06 AM »
Summary
Attached is a profile that allows you to change the mouse movement speed while an input trigger (like a keyboard key) is held down. This is useful for applications where on-demand fine (or swift) mouse control is beneficial, such as when performing digital editing or simply aiming at something.

VoiceAttack Version Required
v1.8.6

Disclaimer
I am not responsible for anything you do to your PC. If that doesn't sit well with you, then it's time to bail out now ;)

How It Works
The profile has a single command that is configured to slow the mouse movement speed while a specific key is held down, and the mouse movement speed returns to its starting value when the key is released. The real magic is inside the command's inline function. Basically the inline function has methods to obtain and change the mouse's pointer speed as displayed in the Control Panel -> Mouse Properties window:



While the trigger key is held down, the inline function runs (and loops) in the background while the command also loops. Once the trigger key is released, all processing stops looping and the mouse movement speed is reset before everything terminates. If a 'Stop Commands' action is encountered while the movement speed is being altered (trigger still held down), then the movement speed will immediately reset to its original value and the command will terminate.

Controls
Currently the triggering key is the LEFT SHIFT key, however this may be changed to a different key or another kind of input (such as mouse or gamepad) by simply adjusting the command trigger and the 'Start Loop While : XXX Is Pressed' device state (see below image for matching highlighted areas).



Inputs
You may specify the mouse movement speed via the ~~MouseSpeed variable. The value must be between 1 (slowest) and 20 (fastest), and the default value for my system is 10. The profile is released with the value set as 2, which should significantly slow down the mouse speed when the command is active.

You also have the option to show or hide event log updates by setting ~~OutputMouseSpeedUpdates to true or false, respectively.

Notes
  • Making changes to the content within the 'VoiceAttack Processing' section of the command (especially the inline function) is NOT recommended unless you know what you are doing
  • All actions within the command as well as all code within the inline function have detailed comments, so you should be able to follow along with what is going on
  • AGAIN, if you want to change the command to utilize a different trigger key press or a different trigger mechanism entirely, you MUST make sure the command trigger matches the 'Start Loop While : XXX Is Pressed' device state
  • Make sure the command trigger's 'do not allow XXX to be passed through' option is NOT checked
  • I've only performed testing for the released configuration. It is possible to make changes/additions to this profile so that you have a way to alter the mouse movement speed in a more permanent manner. For example, you could create separate commands: one for changing the mouse movement speed to a specified value and another for resetting the speed back to the initial value. I have NOT tested if this kind of change would "stick" between PC reboots. However, if you can navigate to the Mouse Properties window illustrated above you should be able to check and undo any mouse movement speed changes you make with the provided functionality.
Special Thanks
Steve_XM for suggesting the idea for fine mouse movement

Support This and Future Efforts
If you find this profile useful, please consider buying me a cup of coffee. Thank you for your support!
 


Happy hunting :)