1打开,0关闭
保存test.bat,文件ansi编码- #&cls&@powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression" &pause&exit
- $code=@'
- using System;
- using System.Runtime.InteropServices;
- public struct STICKYKEYS{
- public int cbSize;
- public int dwFlags;
- }
- public static class WinApi{
- [DllImport("user32.dll")]
- public static extern bool SystemParametersInfo(int act, int param, ref STICKYKEYS sk, int ini);
- }
- '@
- Add-Type -TypeDefinition $code
- #shift5次快捷键 0关闭 1打开
- $b_shift = 0
- $sk = New-Object 'STICKYKEYS' -Property @{ 'cbSize'=8 }
- [WinApi]::SystemParametersInfo(58,8,[ref]$sk,0)
- $sk.dwFlags = $sk.dwFlags -band -5 -bor ($b_shift * 4)
- [WinApi]::SystemParametersInfo(59,8,[ref]$sk,3)
复制代码
|