• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Turn monitors on and off

Windows
8
17
6.7k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    Russ
    last edited by Russ Apr 29, 2020, 3:45 PM Apr 29, 2020, 3:36 PM

    Turn monitors 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)
    

    Turn monitors on (didn't work for me - see below):

    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,-1)
    

    In my case, the Turn monitors on powershell command didn't work for me. My monitors turned on but then turned right back off for some reason. So instead, I used this script and made this my command line so it effectively presses the Print Scrn button to turn my monitors back on:

    wscript d:\scripts\key.vbs PRTSC
    

    Russell VanderMey

    R 1 Reply Last reply Sep 18, 2020, 2:13 PM Reply Quote 1
    • T
      Trenton Lawson
      last edited by May 20, 2020, 4:08 AM

      @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?

      R 1 Reply Last reply May 20, 2020, 11:56 AM Reply Quote 0
      • R
        Russ @Trenton Lawson
        last edited by May 20, 2020, 11:56 AM

        @Trenton-Lawson unfortunately I think the problem is specific to your hardware.

        Russell VanderMey

        T 1 Reply Last reply May 23, 2020, 3:26 PM Reply Quote 0
        • ?
          A Former User
          last edited by A Former User May 21, 2020, 11:14 AM May 21, 2020, 11:12 AM

          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)

          1 Reply Last reply Reply Quote 0
          • T
            Trenton Lawson @Russ
            last edited by May 23, 2020, 3:26 PM

            @Russ Is it possible one of my apps could be preventing it? Such as Wallpaper Engine which creates live wallpapers.

            R 1 Reply Last reply May 23, 2020, 3:28 PM Reply Quote 0
            • R
              Russ @Trenton Lawson
              last edited by May 23, 2020, 3:28 PM

              @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.

              Russell VanderMey

              T 1 Reply Last reply May 23, 2020, 3:49 PM Reply Quote 0
              • T
                Trenton Lawson @Russ
                last edited by May 23, 2020, 3:49 PM

                @Russ Any idea on what piece of hardware might be causing the issue? If not no worries

                R 1 Reply Last reply May 23, 2020, 5:31 PM Reply Quote 0
                • R
                  Russ @Trenton Lawson
                  last edited by May 23, 2020, 5:31 PM

                  @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.

                  Russell VanderMey

                  1 Reply Last reply Reply Quote 0
                  • X
                    Xander
                    last edited by May 25, 2020, 2:44 PM

                    NirCMD (https://www.nirsoft.net/utils/nircmd.html) can do this with a single command: nircmd.exe monitor off

                    1 Reply Last reply Reply Quote 1
                    • R
                      raeyatd
                      last edited by Aug 3, 2020, 1:46 AM

                      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.

                      R 1 Reply Last reply Aug 3, 2020, 1:49 AM Reply Quote 0
                      • R
                        raeyatd @raeyatd
                        last edited by Aug 3, 2020, 1:49 AM

                        @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

                        R 1 Reply Last reply Aug 4, 2020, 1:41 AM Reply Quote 0
                        • R
                          Russ @raeyatd
                          last edited by Aug 4, 2020, 1:41 AM

                          @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) +"}"

                          Russell VanderMey

                          1 Reply Last reply Reply Quote 0
                          • R
                            Rhadson Matias @Russ
                            last edited by Sep 18, 2020, 2:13 PM

                            @Russ

                            I have more than one monitor, can you choose which one to turn off?

                            R 1 Reply Last reply Sep 19, 2020, 1:03 AM Reply Quote 0
                            • R
                              Russ @Rhadson Matias
                              last edited by Russ Sep 19, 2020, 1:06 AM Sep 19, 2020, 1:03 AM

                              @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.

                              Russell VanderMey

                              S 1 Reply Last reply Mar 18, 2021, 12:26 AM Reply Quote 0
                              • S
                                SniperVB @Russ
                                last edited by Mar 18, 2021, 12:26 AM

                                @Russ Hii, did you find a way to turn a specific monitor off? Or at least just a second screen?

                                1 Reply Last reply Reply Quote 0
                                • X
                                  Xander
                                  last edited by Mar 18, 2021, 3:15 PM

                                  "Enable/disable/configure multiple monitors on Windows"
                                  https://www.nirsoft.net/utils/multi_monitor_tool.html

                                  MultiMonitorTool.exe /disable \.\DISPLAY3

                                  And, for single monitors, my comment from a year ago still works.

                                  1 Reply Last reply Reply Quote 3
                                  • Fernando Montes VázquezF
                                    Fernando Montes Vázquez
                                    last edited by Jun 8, 2021, 12:07 PM

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post