Turn monitors on and off
-
@Russ said in Turn monitors on and off:
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)
When I try and run the turn monitors off command, it works briefly, but my screen wakes up after maybe three seconds. While my monitors are off my keyboard and mouse flash rapidly at me. Any idea on how to fix this?
-
@Trenton-Lawson unfortunately I think the problem is specific to your hardware.
-
I get an error when running the monitor off command:
PS C:\Windows\System32\WindowsPowerShell\v1.0> 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 : c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : Unexpected character '\' c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(7) : { c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : >>> [DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(9) : At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : Newline in constant c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(7) : { c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : >>> [DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(9) : At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : Invalid expression term '' c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(7) : { c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : >>> [DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(9) : At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : ) expected c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(7) : { c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : >>> [DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(9) : At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : Invalid token '"user32.dll")]^public stati...' in class, struct, or interface member declaration c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(7) : { c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(8) : >>> [DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); c:\Users\xxx\AppData\Local\Temp\xzybaz5r.0.cs(9) : At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Except ion + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : Cannot add type. Compilation errors occurred. At line:1 char:13 + powershell (Add-Type '[DllImport(\"user32.dll\")]^public static exter ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Add-Type], InvalidOperationException + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
(Just a note: I've been using Nircmd to do this, it does the same)
-
@Russ Is it possible one of my apps could be preventing it? Such as Wallpaper Engine which creates live wallpapers.
-
@Trenton-Lawson, it's possible because I don't know specifically why it's doing that, but I doubt that's it. It seems more like a hardware problem.
-
@Russ Any idea on what piece of hardware might be causing the issue? If not no worries
-
@Trenton-Lawson, maybe the video card or monitor, but it might even be the motherboard because of what you told me about the keyboard and mouse flashing.
-
NirCMD (https://www.nirsoft.net/utils/nircmd.html) can do this with a single command: nircmd.exe monitor off
-
someone help me!!! when I use the command 'wscript d: \ scripts \ key.vbs PRTSC' it says that the script file 'd: \ scripts \ key.vbs' could not be found.
-
@raeyatd said in Turn monitors on and off:
someone help me!!! when I use the command 'wscript d: \ scripts \ key.vbs PRTSC' it says that the script file 'd: \ scripts \ key.vbs' could not be found.
@Russ please
-
@raeyatd, for that to work, you'd need to have a drive with a scripts folder in the root of it, and you'd need to create the key.vbs file. If you don't have a drive, you could use your drive.
These are the contents of that key.vbs for quick reference:
Dim Wsh Set Wsh = Wscript.CreateObject("Wscript.Shell") Wsh.SendKeys "{" + WScript.Arguments.Item(0) +"}"
-
I have more than one monitor, can you choose which one to turn off?
-
@Rhadson-Matias, I don't know of any tools that can turn specific monitors off. I'll have to do some research.
At first I thought you were asking if you can shutdown a second computer. For that you could say something like this:
Alexa, turn off power on laptop.
Power is the voice word for the command on the computer with laptop as its voice word.
-
@Russ Hii, did you find a way to turn a specific monitor off? Or at least just a second screen?
-
"Enable/disable/configure multiple monitors on Windows"
https://www.nirsoft.net/utils/multi_monitor_tool.htmlMultiMonitorTool.exe /disable \.\DISPLAY3
And, for single monitors, my comment from a year ago still works.
-
This post is deleted!