Turn monitor off

From WickyWiki


Script to turn your monitor off.

$usr32 = Add-Type  -Name usr32 -Pas -Mem '
    [DllImport("user32.dll")]
    public static extern int PostMessage(int h,int m,int w,int l);'
$usr32::PostMessage(-1,0x0112,0xF170,2)

Quick access to this function is possible via a Windows shortcut. Create one and right click to open the properties, add the following as command (Target):

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (Add-Type '[DllImport(\"user32.dll\")]public static extern int PostMessage(int h,int m,int w,int l);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)

If you want access via a key-combination (for example CTRL+SHIFT+F12) you can specify this as the 'Shortcut key' in the shortcut properties.