将PowerShell命令转换为脚本

将PowerShell命令转换为脚本,powershell,Powershell,从批处理文件(或命令提示符)运行时,下面的PowerShell命令将关闭屏幕。我更愿意将其作为PowerShell脚本运行 powershell(添加类型“[DllImport(\'user32.dll')”)^public static extern int SendMessage(int hWnd、int hMsg、int wParam、int lParam);' -说出一个 -Pas):发送消息(-1,0x0112,0xF170,2) 我看了一下,但是我不能得到正确的参数 此操作的等效P

从批处理文件(或命令提示符)运行时,下面的PowerShell命令将关闭屏幕。我更愿意将其作为PowerShell脚本运行

powershell(添加类型“[DllImport(\'user32.dll')”)^public static
extern int SendMessage(int hWnd、int hMsg、int wParam、int lParam);'
-说出一个
-Pas):发送消息(-1,0x0112,0xF170,2)

我看了一下,但是我不能得到正确的参数


此操作的等效PowerShell脚本是什么?

[Win32Functions.Win32SendMessage]::SendMessage(-1,0x0112,0xF170,-1)
打开监视器。
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)