Created
June 17, 2020 10:27
-
-
Save jstangroome/eec58484f8060b44ecc23d383ad22d94 to your computer and use it in GitHub Desktop.
Change the mouse drag distance required to initiate a drag operation, e.g. moving files in Explorer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[int]$drag = 4 | |
) | |
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa | |
$importDefinition= @' | |
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")] | |
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni); | |
'@ | |
$importType = Add-Type -MemberDefinition $importDefinition -Name WinAPICall -Namespace SetDragSystemParametersInfo –PassThru | |
$SPI_SETDRAGWIDTH=0x004C | |
$SPI_SETDRAGHEIGHT=0x004D | |
$SPIF_UPDATEINIFILE = 0x1 # persist the change between login sessions (not actually via .ini file) | |
$SPIF_SENDCHANGE = 0x2 # apply the change to the current session without logging out, and back in. | |
$importType::SystemParametersInfo($SPI_SETDRAGWIDTH, $drag, $null, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) | |
$importType::SystemParametersInfo($SPI_SETDRAGHEIGHT, $drag, $null, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The posted code got corrupted somewhere along the way.
–PassThru
should be-PassThru
The former string has a Unicode hyphen which will cause an error that displays as
–PassThru