hey guys! im making this program for myself called shourtcut keys(so far, so good) :) so anyway i was wondering if there was a code to turn off the monitor by pressing a key on the keyboard and to turn it on. i keep on searching on google and here but whatever i get turns it of and than a second later turns it back on. its because they think that im clicking a button and say not to touch the mouse or keyboard after its turned off. so it turns back on when i press the key. hope u can help.

4 Years
Discussion Span
Last Post by dternity

yes that works but its not what im looking for. i dont like the code i have right now:

Private Const MONITOR_OFF As Integer = 2
    Private SC_MONITORPOWER As Integer = &HF170
    Private WM_SYSCOMMAND As Integer = &H112

    If e.KeyValue = Keys.M Then


        End If

    <DllImport("user32.dll", SetLastError:=True)> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
    End Function

    <DllImport("user32.dll")> Private Shared Function SendMessage(ByVal hWnd As Integer, ByVal hMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function

    Public Sub TurnOffLCD()
        Dim num As Integer = 0
        num = SendMessage(FindWindow(Nothing, Nothing).ToInt32, Me.WM_SYSCOMMAND, Me.SC_MONITORPOWER, 2)
    End Sub

i want code that will completely turn off and on the monitor without putting it in power saving mode. can someone help???


What you are doing is trying to manipulate hardware with software. You will have to contact the manufacturer of the LCD to see if the LCD allows that functionaly. Closest thing I know of would be to kill power to the GPU. (dangerous, would not reccommend doing this)

I think you are wanting a sleep, right?

Something like this would do that:

Application.SetSuspendState(PowerState.Suspend, True, False)

Edited by Begginnerdev


no because of 2 things. ur code makes the computer standby altogether, and when i say i want the monitor to shut off altogether, i want the light on the monitor 2 go out, as if i just press the monitor button with code. i dont know if this helps but im use a desktop windows xp pro. and im just gonna guess that ur using mac because mac has the screen attached 2 it.


It is not possible (that I know of) to physically turn off a monitor (simulate the power button being pressed) via code. Again, I would check with your monitor manufacturer to see if they are a rare exception to this.

To do as you wish, you would have to kill power to the monitor. The monitor being a peripheral device - this would not be possible unless you speak with the hardware in the device. I do not know of any manufacturers that support 100% power termination via software.


Surely if Windows can turn on/off the power to various devices such as monitor, hard drive, etc based on user settings then there must be some way for an application to do the same with the proper API call.


What you want to do is turn off the power supply switch via a software command. I have never seen this type of functionality and do not believe it exists at least not in any published standard.

From the ACPI Specification: http://acpi.info/DOWNLOADS/ACPIspec40a.pdf

A.2.2 Display Power Management

Refer to the Display Power Management Signaling Specification (DPMS), available from:

Video Electronics Standards Association (VESA)
2150 North First Street
Suite 440
San Jose, CA 95131-2029

A DPMS-compliant video controller and DPMS-compliant monitor use the horizontal and vertical sync signals to control the power mode of the monitor. There are 4 modes of operation: normal, standby, suspend and off. DPMS-compliant video controllers toggle the sync lines on or off to select the power mode.

For more entertaining reading: http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/DspPMSpc.rtf


ok i think this is WAY to complicated for me so i guess im not gonna use that function in the program. thx for trying to help! :)


Well if you want to make the user unable to see anything on the monitor you could just make a form with full-screen with a black background and he won't be able to see anything. I made a lock screen program that couldn't be closed (CRTL+ALT+Delete, Alt-Tab etc... didn't work) If you want i can send it to you and you could look at the source.

Best fo luck :)

Edit: the post is 1 year old -.-

Edited by dternity

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.