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

    Turn monitors on and off

    Scheduled Pinned Locked Moved Windows
    17 Posts 8 Posters 15.6k Views 2 Watching
    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.
    • ? Offline
      [[global:former-user]]
      last edited by [[global:former-user]]

      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
      • Trenton LawsonT Offline
        Trenton Lawson @Russ
        last edited by

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

        RussR 1 Reply Last reply Reply Quote 0
        • RussR Offline
          Russ @Trenton Lawson
          last edited by

          @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

          Trenton LawsonT 1 Reply Last reply Reply Quote 0
          • Trenton LawsonT Offline
            Trenton Lawson @Russ
            last edited by

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

            RussR 1 Reply Last reply Reply Quote 0
            • RussR Offline
              Russ @Trenton Lawson
              last edited by

              @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
              • XanderX Offline
                Xander
                last edited by

                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 0
                • R Offline
                  raeyatd
                  last edited by

                  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 Reply Quote 0
                  • R Offline
                    raeyatd @raeyatd
                    last edited by

                    @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

                    RussR 1 Reply Last reply Reply Quote 0
                    • RussR Offline
                      Russ @raeyatd
                      last edited by

                      @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
                      • Rhadson MatiasR Offline
                        Rhadson Matias @Russ
                        last edited by

                        @Russ

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

                        RussR 1 Reply Last reply Reply Quote 0
                        • RussR Offline
                          Russ @Rhadson Matias
                          last edited by Russ

                          @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 Reply Quote 0
                          • S Offline
                            SniperVB @Russ
                            last edited by

                            @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
                            • XanderX Offline
                              Xander
                              last edited by

                              "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 2
                              • Fernando Montes VázquezF Offline
                                Fernando Montes Vázquez
                                last edited by

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

                                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                With your input, this post could be even better 💗

                                Register Login
                                • First post
                                  Last post