Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: VisualBasic | Size: 1.01 KB | Hits: 128 | Expires: Never
Copy text to clipboard
  1. Imports System.Runtime.InteropServices
  2.  
  3. Public Class Form1
  4.     Private it As New IdleTime
  5.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  6.         TextBox1.Text = it.IdleTime 'Ambil idle time dalam satuan detik
  7.    End Sub
  8. End Class
  9.  
  10. ' BAGIAN INI BIARIN AJA.. GW JG GA TAU NTAH INI APA WKWKWK..
  11. Public Class IdleTime
  12.     Private Declare Function GetLastInputInfo Lib "User32.dll" _
  13.       (ByRef lastInput As LASTINPUTINFO) As Boolean
  14.  
  15.     <StructLayout(LayoutKind.Sequential)> _
  16.     Public Structure LASTINPUTINFO
  17.         Public cbSize As Int32
  18.         Public dwTime As Int32
  19.     End Structure
  20.  
  21.     Public ReadOnly Property IdleTime() As Integer
  22.         Get
  23.             Dim lastInput As New LASTINPUTINFO
  24.             lastInput.cbSize = Marshal.SizeOf(lastInput)
  25.             If GetLastInputInfo(lastInput) Then
  26.                 Return (Environment.TickCount - lastInput.dwTime) / 1000
  27.             End If
  28.         End Get
  29.     End Property
  30. End Class