¿Cómo puedo apagar el monitor en vb excel, sin que el ratón o el teclado hagan que se vuelva a encender?
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Integer)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Declare Function BlockInput Lib "USER32.dll" (ByVal fBlockIt As Long) As Long
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Sub setMonitor()
Const SC_MONITORPOWER As Long = &HF170&
Const WM_SYSCOMMAND As Long = &H112&
Const MONITOR_ON As Long = -1&
Const MONITOR_OFF As Long = 2&
Const MONITOR_STANDBY As Long = 1&
Debug.Print
Debug.Print Now, "MONITOR STANDBY"
SendMessage Application.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_STANDBY
'bloquea keyboard and mouse
Application.ScreenUpdating = False
Sleep (2000)
BlockInput True ' Turns off Keyboard and Mouse
' Routine goes here
Sleep (2000)
SetCursorPos 300, 1000
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 8000 ' Optional coding
BlockInput False ' Turns on Keyboard and Mouse
End Sub
Consigo que el monitor se apague y bloquear teclado y ratón. Pero al pasarle la instrucción mouse_event el monitor se enciende de nuevo. ¿Es posible evitarlo?
Yo lo que no consigo es que se me vuelva a encender el monitor con la opción -1 - Antonio M
Tal vez por la versión de windows. Lo que hace es apagar por un momento el monitor. La opción que yo puse, si no mal recuerdo, apagar el monitor. - Dante Amor