Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: antonio2005pe en Julio 30, 2015, 02:55:01 am
-
Hola Amigos, uso la api de windows para apagar la pantalla
Public Declare Function SendMessage _
Lib "user32" _
Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Const WM_SYSCOMMAND = &H112&
Const SC_MONITORPOWER = &HF170&
y lo llama asi para apagar la pantalla
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 2&
tengo un formulario con un timer que hace un select al servidor y debe desbloquear el equipo si encuentra algun dato en el select, pero cuando se apaga la pantalla se bloquea el equipo y el formulario deja de funcionar, quiero apagar la pantalla para ahorrar energia, hay alguna forma de hacerlo?
Muchas Gracias.
-
HOLA!!!
Mostra una pantalla blanca o negra segun tu tipo de display para ahorrar bateria del dispositivo:
http://www.smartblog.es/2011/07/como-ahorrar-bateria-en-tu-movil-fondos-de-pantalla/
GRACIAS POR LEER!!!
-
HOLA!!!
Mostra una pantalla blanca o negra segun tu tipo de display para ahorrar bateria del dispositivo:
http://www.smartblog.es/2011/07/como-ahorrar-bateria-en-tu-movil-fondos-de-pantalla/
GRACIAS POR LEER!!!
Muchas gracias por tu respuesta, pero no habria otra forma solo de apagar la pantalla pero no suspender la tablet?, me refiero que si alguien necesita escuchar musica por ejemplo en su tablet en la calle deberia poder apagar solo la pantalla sin que se le apage la musica o algun otro programa en background funcionando.
-
HOLA!!!
Yo creo que la tablet On_Wake va a pedir pass siempre que este configurada de esa manera, se puede quitar el bloqueo de pantalla, pero eso es desde la configuracion de windows no desde tu programa.
GRACIAS POR LEER!!!
-
Muchas gracias, seguire buscando pera ver si encuentro alguna mejor solucion y si la encuentro la pongo aqui para los que tenga el mismo problema.
-
Estimado antonio2005pe
Agrega el siguiente código
En un Formulario
===============================================
Private Sub Form_Load()
Timer1.Interval = 5000
End Sub
Private Sub Timer1_Timer()
DoNotSleep
End Sub
===============================================
En un Modulo
===============================================
Private Enum Execution_State
ES_SYSTEM_REQUIRED = &H1
ES_DISPLAY_REQUIRED = &H2
ES_USER_PRESENT = &H4
ES_CONTINUOUS = &H80000000
End Enum
Private Declare Sub SetThreadExecutionState Lib "kernel32" (ByRef esFlags As Execution_State)
Private Const SPI_SETSCREENSAVETIMEOUT = 15
Private Declare Function SystemParametersInfo Lib "User" (ByVal uAction As Integer, ByVal uparam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As Integer
Public Sub DoNotSleep()
'Sets the screen saver time-out value to the
'value of the uiParam parameter. This value is the amount of time,
'in seconds, that the system must remain idle before the screen saver activates.
'So, if you set it 30, it will suspend the screensaver & Power Off features for 30 minutes
SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 30, 0, 0
SetThreadExecutionState ES_CONTINUOUS Or ES_DISPLAY_REQUIRED Or ES_CONTINUOUS
End Sub
===============================================
Está es otra alternativa, y consiste en que invoques un comando de PowerShell desde VB
powercfg -hibernate off
powercfg -hibernate on
Si requieres más información de PowerShell, te dejo estos link
https://technet.microsoft.com/es-es/library/cc748940(v=ws.10).aspx (https://technet.microsoft.com/es-es/library/cc748940(v=ws.10).aspx)
http://www.techrepublic.com/article/investigate-windows-sleep-states-with-the-powercfg-command/ (http://www.techrepublic.com/article/investigate-windows-sleep-states-with-the-powercfg-command/)
Saludos, desde algún lugar de Lima-Perú
-
Muchas Gracias, lo probare enseguida.
-
Estimado antonio2005pe
Agrega el siguiente código
En un Formulario
===============================================
Private Sub Form_Load()
Timer1.Interval = 5000
End Sub
Private Sub Timer1_Timer()
DoNotSleep
End Sub
===============================================
En un Modulo
===============================================
Private Enum Execution_State
ES_SYSTEM_REQUIRED = &H1
ES_DISPLAY_REQUIRED = &H2
ES_USER_PRESENT = &H4
ES_CONTINUOUS = &H80000000
End Enum
Private Declare Sub SetThreadExecutionState Lib "kernel32" (ByRef esFlags As Execution_State)
Private Const SPI_SETSCREENSAVETIMEOUT = 15
Private Declare Function SystemParametersInfo Lib "User" (ByVal uAction As Integer, ByVal uparam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As Integer
Public Sub DoNotSleep()
'Sets the screen saver time-out value to the
'value of the uiParam parameter. This value is the amount of time,
'in seconds, that the system must remain idle before the screen saver activates.
'So, if you set it 30, it will suspend the screensaver & Power Off features for 30 minutes
SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 30, 0, 0
SetThreadExecutionState ES_CONTINUOUS Or ES_DISPLAY_REQUIRED Or ES_CONTINUOUS
End Sub
===============================================
Está es otra alternativa, y consiste en que invoques un comando de PowerShell desde VB
powercfg -hibernate off
powercfg -hibernate on
Si requieres más información de PowerShell, te dejo estos link
https://technet.microsoft.com/es-es/library/cc748940(v=ws.10).aspx (https://technet.microsoft.com/es-es/library/cc748940(v=ws.10).aspx)
http://www.techrepublic.com/article/investigate-windows-sleep-states-with-the-powercfg-command/ (http://www.techrepublic.com/article/investigate-windows-sleep-states-with-the-powercfg-command/)
Saludos, desde algún lugar de Lima-Perú
Estimado Albertomi, me sale un error en el Timer "Error 53 en tiempo de ejecucion, No se a encontrado el archivo: User"
Gracias.
-
Estimado antonio2005pe
Reemplaza todo el código del modulo, por el siguiente código
===========================================
Option Explicit
Private Enum Execution_State
ES_SYSTEM_REQUIRED = &H1
ES_DISPLAY_REQUIRED = &H2
ES_USER_PRESENT = &H4
ES_CONTINUOUS = &H80000000
End Enum
Private Declare Sub SetThreadExecutionState Lib "kernel32" (ByRef esFlags As Execution_State)
Const SPI_SETSCREENSAVETIMEOUT = 15
Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal fWinIni As Long) As Long
Public Sub DoNotSleep()
'Sets the screen saver time-out value to the
'value of the uiParam parameter. This value is the amount of time,
'in seconds, that the system must remain idle before the screen saver activates.
'So, if you set it 30, it will suspend the screensaver & Power Off features for 30 minutes
SystemParametersInfo SPI_SETSCREENSAVETIMEOUT, 30, 0, 0
SetThreadExecutionState ES_CONTINUOUS Or ES_DISPLAY_REQUIRED Or ES_CONTINUOUS
End Sub
===========================================
Saludos, desde algún lugar de Lima-Perú
-
Muchas Gracias, me funciono de maravilla :).