Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: Rudy21 en 17 Octubre 2008, 21:24 PM

Título: Saber Si Pc Está Inactiva
Publicado por: Rudy21 en 17 Octubre 2008, 21:24 PM
Pues Necesito saber eso


si una pc está inactiva por ejemplo apagarla

c me ocurrio esto:

inicia TIMER, registra la posicion de el mouse en 2 textbox X & Y

si al trascurrir el tiempo la posision del mouse es igual a la de x & y

(igual a inactividad) apagar

en caso de cambiar el valor de el textbox o de presionar na tecla

se renicia el timer

alguna idea?

gracias
Título: Re: Saber Si Pc Está Inactiva
Publicado por: cobein en 17 Octubre 2008, 21:28 PM
podes usar GetLastInputInfo
Título: Re: Saber Si Pc Está Inactiva
Publicado por: Karcrack en 17 Octubre 2008, 22:16 PM
Bueno, he hecho un ejemplo de uso, lo reconozco, me aburria mucho :xD:


Has de agregar un Timer con intervalo 100, y cuando lleves 5 segundos inactivo se mostrara un msgbox...

Código (vb) [Seleccionar]
Option Explicit

Private Type PLASTINPUTINFO
    cbSize      As Long
    dwTime      As Long
End Type

Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function GetLastInputInfo Lib "user32.dll" (ByRef plii As PLASTINPUTINFO) As Long

'---------------------------------------------------------------------------------------
' Procedure : GetIdleMs
' Author    : Karcrack
' Date      : 17/10/2008
' Purpose   : Obtiene los Ms desde el ultimo movimiento del usuario.
'---------------------------------------------------------------------------------------
'
Public Function GetIdleMs() As Double
    Dim PlastII         As PLASTINPUTINFO
   
    PlastII.cbSize = Len(PlastII)
   
    Call GetLastInputInfo(PlastII)
   
    GetIdleMs = GetTickCount - PlastII.dwTime
End Function

'---------------------------------------------------------------------------------------
' Procedure : Timer_Timer
' Interval  : 100 ms
'---------------------------------------------------------------------------------------
'
Private Sub Timer_Timer()
    If GetIdleMs > 5000 Then
        MsgBox "Llevas 5 segundos inactivo."
    End If
End Sub


Saludos :D