One user wanted to know how to configure the "Animate windows when minimizing and maximizing" performance setting from the command line. There is a Registry entry that directly represents that checkbox, but tweaking that value doesn't cause a behavior change until after a logon/logoff cycle. The correct way to programmatically adjust the setting is via the
SystemParametersInfo function, so this calls for some PowerShell and P/Invoke. (It would be a great opportunity to showcase my P/Invoke command-line tool, but it's not ready for release yet.) The call is made somewhat tricky by the need for a special structure, so jamming the entire thing into one PowerShell run would be unwieldy, but it's fine as a script:
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)] public struct ANIMATIONINFO {
public uint cbSize;
public bool iMinAnimate;
}
public class PInvoke {
[DllImport("user32.dll")] public static extern bool SystemParametersInfoW(uint uiAction, uint uiParam, ref ANIMATIONINFO pvParam, uint fWinIni);
}
"@
$animInfo = New-Object ANIMATIONINFO
$animInfo.cbSize = 8
$animInfo.iMinAnimate = $args[0]
[PInvoke]::SystemParametersInfoW(0x49, 0, [ref]$animInfo, 3)
It takes a Boolean value specifying whether to enable window minimize/restore animations.
No comments:
Post a Comment