Private Const MONITOR_ON = -1&
Private Const MONITOR_LOWPOWER = 1&
Private Const MONITOR_OFF = 2&
Private Const SC_MONITORPOWER = &HF170&
Private Const WM_SYSCOMMAND = &H112
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Form_Load()
Command1.Caption = "Turn off monitors"
End Sub
Private Sub Command1_Click()
Call SendMessage(Me.hWnd, WM_SYSCOMMAND, _
SC_MONITORPOWER, ByVal MONITOR_OFF)
With Timer1
.Interval = 8000
.Enabled = True
End With
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
Call SendMessage(Me.hWnd, WM_SYSCOMMAND, _
SC_MONITORPOWER, ByVal MONITOR_ON)
End Sub
No comments:
Post a Comment