Home
About Me!
Projects
Research
Links
Gallery
Travel
   
Random Header Image
Disable Enable
More Info



Monitor Standby

Overview:
I found it frustrating that Windows did not have an easy way to quickly switch the monitor into standby mode. I remember years ago when using Afterdark on the Apple Macintosh it was possible to activate the screensaver by moving the mouse to a specified corner of the screen. I wanted something similar to this that would either turn the monitor off or put it into standby mode.

The Solution:
I accomplished this by creating a very small VB executable along with a program called WinKey. I used the WinKey program to bind the windows key and "o" to the executable. Therefore when the windows key and "o" were pressed simultaneously the executable would be run and therefore turn off the monitor.

The Code:
The following code simply calls one of the Windows API functions to make the monitor go either into Standby mode or Off mode. The code below turns the monitor into Standby mode. To make the monitor turn off instead, use the following line instead in the monitorStandby sub:

SendMessage(AnyForm.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, 2&)

Note: The form form should be called frmStandby.

VB Code for Monitor Standby
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
  (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MONITORPOWER = &HF170&

Private lRet As Long

Public Sub monitorStandby()
  lRet = SendMessage(frmStandby.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, 1&)
End Sub

Private Sub Form_Load()
  Call Sleep(1000)
Call monitorStandby
End
End Sub

Download:
You can download the executable versions below:

Monitor Off
Monitor Standby

Note: You may need to download the visual basic runtime files.