Here is another good tip which you may find helpfull.
Lets say you want to control the Monitor’s power state (On/Standby) via VB.
In my case, my Den holds my wife’s and my computer. The program already (using the before mentioned X10 sensors) detects movement after sunset it will ‘talk’ the weather of two zip codes (Home and work) but I would like it also to ‘bring’ back the computer from its monitor power saving mode, so even before I touch the mouse, the computer is waiting for me.
Basically the code does is calls directly to the User32 library (like to good old VB6 days). In case we will alter the SC_MONITORPOWER state from -1, to 0, and calling other System values in HEX.
Below is how its done in VB 2005 / .NET,
Here is the same thing but in “C” code, I basically converted it from here.
1st we will define the Function that will be called,
2nd We will define 2 subroutines or functions that we can call I called them “WakeUp” and “Sleep.
Again this only consist of the monitor ‘power’ state, the computer is not on standby or hibernation. Many of today’s computer now have WOL capability BUT only for wired (Cat 5) connections, in my case I use USB wireless all around the house and I haven’t gotten that part to work yet.
Public Class Form1 '-------------- FUNCTION TO WAKE UP SCREEN Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Dim WM_SYSCOMMAND As Integer = &H112 Dim SC_MONITORPOWER As Integer = &HF170 Dim HWND_BROADCAST As Integer = &HFFFF Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ... all your startup code here... Public Sub Wakeup() Beep() '---- Just for fun SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, -1) End Sub Public Sub Sleep() SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) End Sub