下面的PowerShell命令在从批处理文件(或命令提示符)运行时关闭屏幕。我更喜欢将其作为PowerShell脚本运行。
Turn Off Screen - TechNet Script Center
powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)
我看了Add-Type - Microsoft Docs,但我无法正确获取参数。
什么是相同的PowerShell脚本?
Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
"@ -Name "Win32SendMessage" -Namespace "Win32Functions"
[Win32Functions.Win32SendMessage]::SendMessage(-1,0x0112,0xF170,2)