Skip to content
 

Windows Drag Sensitivity Utility

Inspired by an article by Raymond Chen about how to correctly change the Windows mouse drag sensitivity, I wrote a quick utility called dragsens. It’s a small command-line utility that will allow you to change the number of pixels the mouse has to travel before a drag operation is initiated. Just download and unzip the utility, then run it at the command line, supplying a single parameter that is the number of pixels for the mouse to travel.

If you’d like modify the utility, or examine its source, you may download the Visual Studio 2008 project. If you just want the utility itself, you may download a ZIP of the executable.

About the Utility

The utility is actually very simple. It accepts a single parameter, which is the number of pixels the mouse must travel with a button depressed before the motion registers as a drag action. Rather than separate out the width and height, I just set both to the same number since this is generally all that’s necessary.

BOOL success = FALSE;

success = SystemParametersInfo(SPI_SETDRAGWIDTH, numPixels, NULL, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);

if (!success)
{
  DWORD error = GetLastError();
  std::wcout < < L"Error " << std::hex << error << std::dec << " while setting drag width." << std::endl;
  return 1;
}

success = SystemParametersInfo(SPI_SETDRAGHEIGHT, numPixels, NULL, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);

if (!success)
{
  DWORD error = GetLastError();
  std::wcout << L"Error " << std::hex << error << std::dec << " while setting drag height." << std::endl;
  return 1;
}

It would be fairly simple to modify the application to set the width and height independently, if you so desired.

Update

I’m already at version 1.1. I decided to add a version resource and support for a “/?” parameter.

Share

9 Comments

  1. acatalept says:

    Great work, and a huge help. Been trying to find a solution to this for a long time.

    Note that one can effectively disable Windows's native drag and drop completely by setting this threshold great than the display's resolution (e.g., 2000 for a 1920×1080 display).

    Thanks!

  2. Anonymous says:

    Thank you so much!! I've been looking for something like this since I'm not a programmer.

  3. Paul M. Parks says:

    You're quite welcome. I'm glad you found it useful.

  4. Meir says:

    I looked all over the internet to no avail, until I found the solution here.
    Simple Elegant and more importantly It Works.

    Thanks a million.

    Meir.

  5. Craig says:

    As soon as I run the program, the command prompt instantly closes. Help?

    • Did you open the command prompt prior to running dragsens? If you run the utility with no parameters from an already-open command prompt it will display some help text and exit, returning you to the prompt. If you just run the utility by itself, it will open a new command prompt and then immediately close it.

  6. Brian says:

    Paul-

    This is a wonderful tool for us IT managers who know very limited programming! Thank you. Is there any way that you know of to embed this in a GPO?

    And, once this setting is applied, does it remain in place after logon/logoff and/or reboot?

    Lastly, is this setting computer based or user based? XP and Win7 clients.

    Thank you again!

    • Sorry I didn’t get back to you sooner! The comment got lost in the shuffle somehow. The setting should remain in place after logoff, as the call to SystemParametersInfo specifies the SPIF_UPDATEINIFILE flag so that the user profile is updated with the change.

      I’m afraid I don’t know how to make this part of a group policy; I suppose you could call it from a login script, but that seems clunky. I’m not much of an admin, though.

  7. Lance says:

    Thank you. This is such an annoying problem – obviously not just for this IT person. I can’t thank you enough for this simple and very effective fix.

Leave a Reply

*