Lock Computer and Turn Off Monitor - Add to Desktop Context Menu

Page 2 of 2 FirstFirst 12

  1. Posts : 73,406
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #10

    Akip said:
    Is there any way to only turn off the monitor without locking the computer?
    Sure. You could use this below instead for that. :)

    Turn Off Display - Add to Desktop Context Menu in Windows
      My Computer


  2. Posts : 22
    Windows 7 Home Premium 32bit
       #11

    Brink said:
    Akip said:
    Is there any way to only turn off the monitor without locking the computer?
    Sure. You could use this below instead for that. :)

    Turn Off Display - Add to Desktop Context Menu in Windows
    Thats what I looking for. Thanks Shawn :)
      My Computer


  3. Posts : 73,406
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #12

    You're most welcome. :)
      My Computer


  4. Posts : 1
    Windows 10 Education
       #13

    Akip said:
    Is there any way to only turn off the monitor without locking the computer?
    You can turn off the monitor the workstation without a 3rd party program with a PowerShell-script: Make a MonitorOff.ps1 for example in C:\ and create a shortcut with this target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy UnRestricted -File C:\MonitorOff.ps1

    Paste the following code inside the .ps1 file:

    Code:
    # Turn display off by calling WindowsAPI.
     
    # SendMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_MONITORPOWER, POWER_OFF)
    # HWND_BROADCAST    0xffff
    # WM_SYSCOMMAND    0x0112
    # SC_MONITORPOWER    0xf170
    # POWER_OFF          0x0002
     
    Add-Type -TypeDefinition '
    using System;
    using System.Runtime.InteropServices;
     
    namespace Utilities {
        public static class Display
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            private static extern IntPtr SendMessage(
                IntPtr hWnd,
                UInt32 Msg,
                IntPtr wParam,
                IntPtr lParam
            );
     
            public static void PowerOff ()
            {
                SendMessage(
                    (IntPtr)0xffff, // HWND_BROADCAST
                    0x0112,            // WM_SYSCOMMAND
                    (IntPtr)0xf170, // SC_MONITORPOWER
                    (IntPtr)0x0002  // POWER_OFF
                );
            }
        }
    }
    '
    [Utilities.Display]::PowerOff()
     
     
    if ($Host.Name -eq 'ConsoleHost') {Stop-Process $PID}
    Last edited by Brink; 12 Sep 2015 at 22:23. Reason: code box
      My Computer


  5. Posts : 3
    Windows 7
       #14

    Can we use this in Windows 10 operating system.
      My Computer


  6. Posts : 73,406
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #15

    Hello Sara, :)

    I haven't tested this in Windows 10 yet, but it should work.
      My Computer


  7. Posts : 3
    Windows 7
       #16

    I am going to use it on my Windows 10 PC. if it is work properly, I will post my experience here.
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:14.
Find Us