Reputation: 13769
The PowerShell command below turns off the screen when run from a batch file (or command prompt). I would prefer to run this as a PowerShell script.
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)
I looked at Add-Type - Microsoft Docs, but I could not get the parameters correct.
What is the equivalent PowerShell script for this?
Upvotes: 1
Views: 1406
Reputation: 1263
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)
Upvotes: 3