Windows: Disable automatic Window arranging and resizing while dragging with the mouse (AeroSnap)

Sometimes the Windows 7 functionality to automatically arrange or resize a window while dragging is a pain. This feature is called Aero Snap. Here are good news, you can disable the behaviour :-).

Open the Control Panel, go to “Ease of Access center”. If you are there, click “Make the mouse easier to use” and enable “Prevent Windows from being automatically arranged when moved to the edge of the screen”.

Mouse Settings

Disable Aero Snap

Or do it with the powershell script below :-). The script calls the windows API function SystemInfoNonRef from User32.dll. Adjust $iSetDisable to alter the setting as you want. This script is also an example how to call Windows API functions from Powershell.

###############################################################################
# Disables the Windows AeroSnap Feature
# created:
# Michael Albert
# 07/17/2013
# info@michlstechblog.info
# License: GPLv2
# References:
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724947%28v=vs.85%29.aspx#Time-out
# http://blogs.technet.com/b/stefan_gossner/archive/2010/05/07/using-csharp-c-code-in-powershell-scripts.aspx
# http://msdn.microsoft.com/de-de/library/cc431203.aspx
###############################################################################

# Using C# to Call the WinAPI
$sCSSource=@"
	using System.Runtime.InteropServices;
	namespace info.michlstechblog
	{
	    public class apicall
	    {
	        public static bool SystemInfoByRef(uint iAction, uint iParameter, ref uint pParameter, uint iWinIni)
	        {
	            return SystemParametersInfo(iAction, iParameter, ref pParameter, iWinIni);
	        }

	        public static bool SystemInfoNonRef(uint iAction, uint iParameter, uint pParameter, uint iWinIni)
	        {
	            return SystemParametersInfo(iAction, iParameter, pParameter, iWinIni);
	        }

	        [DllImport("User32.dll")]
	        private static extern bool SystemParametersInfo(uint iAction, uint iParameter, ref uint pParameter, uint iWinIni);

	        [DllImport("User32.dll")]
	        private static extern bool SystemParametersInfo(uint iAction, uint iParameter, uint pParameter, uint iWinIni);
	    }
	}
"@
Add-Type -ReferencedAssemblies $Assem -TypeDefinition $sCSSource -Language CSharp
# Get Current Setting
# SPI_GETWINARRANGING 0x0082
$bCurrentState=0
If([info.michlstechblog.apicall]::SystemInfoByRef(0x0082, 0, ([REF]$bCurrentState), 0)){
	write-host -NoNewline ("""Prevent Windows from being automatically arranged when moved to the edge of the screen"" is ")
	if($bCurrentState -eq 0){
		write-host "enabled"
	}
	elseif($bCurrentState -eq 1){
		write-host "disabled"
	}
	else{
		write-host "in unknown state"
	}
}
else{
	Write-Warning " Can't get setting ""Prevent Windows from being automatically arranged when moved to the edge of the screen"""
}
# Enable "Prevent Windows from being automatically arranged when moved to the edge of the screen"
# SPI_SETWINARRANGING = 0x0083
# SPI_SETWINARRANGING , SPI_SETDOCKMOVING
# In the SPI_SETWINARRANGING and SPI_SETDOCKMOVING description, the parameter used to set the value is uiParam, not pvParam.
# Parameter is negative
$iSetDisable=0
if([info.michlstechblog.apicall]::SystemInfoNonRef(0x0083, $iSetDisable, 0, 1)){
	write-host ("Set ""Prevent Windows from being automatically arranged when moved to the edge of the screen"" to enabled ")
}
else{
	Write-Warning " Can't set ""Prevent Windows from being automatically arranged when moved to the edge of the screen"""
}

Have fun.
Michael

DisableAeroSnap
DisableAeroSnap
DisableAeroSnap.ps1
2.8 KiB
1499 Downloads
Details...

One thought on “Windows: Disable automatic Window arranging and resizing while dragging with the mouse (AeroSnap)”

Leave a Reply