- Thread Author
-
- #1
Hi!
I'm new here. I have installed Windows 10.1903 Pro x64.
I'm using many ways to realize tasks. Now I want to ask if is possible to turn on or off monitor (in my case 3 monitors) connected to computer by any command. Best in command line - it needs not extra options, I can plan it by my wish or so, only one option will be useful - specify selected monitor.
Thank you for help.
I'm new here. I have installed Windows 10.1903 Pro x64.
I'm using many ways to realize tasks. Now I want to ask if is possible to turn on or off monitor (in my case 3 monitors) connected to computer by any command. Best in command line - it needs not extra options, I can plan it by my wish or so, only one option will be useful - specify selected monitor.
Thank you for help.
Solution
Someone at Microsoft has created a batch file that turns off all monitors when launched. You can download the batch file from the link above or create one on your own with the following code:
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)
A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:
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)
A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:
Code:
function Set-DisplayOff
{
$code = @"
using System;
using System.Runtime.InteropServices;
public class API
{
[DllImport("user32.dll")]
public...
- Thread Author
-
- #2
AdrianG001
Senior Member
- Joined
- Feb 19, 2018
- Messages
- 108
Someone at Microsoft has created a batch file that turns off all monitors when launched. You can download the batch file from the link above or create one on your own with the following code:
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)
A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:
Regards,
Adrian
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)
A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:
Code:
function Set-DisplayOff
{
$code = @"
using System;
using System.Runtime.InteropServices;
public class API
{
[DllImport("user32.dll")]
public static extern
int SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);style='box-sizing: border-box'>
}
"@
$t = Add-Type -TypeDefinition $code -PassThru
$t::SendMessage(0xffff, 0x0112, 0xf170, 2)
}
Set-DisplayOff
Regards,
Adrian
Similar threads
- Article
- Replies
- 0
- Views
- 5
- Replies
- 9
- Views
- 19K