Turn monitor off

From WickyWiki
Revision as of 18:47, 27 March 2021 by Wilbert (talk | contribs) (Created page with "Category:Windows Powershell Category:202103 <!-- sleep monitor display power saving --> Script to turn your monitor off. <source lang=powershell> $usr32 = Add-Type...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


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.