Author : pandikumar
Date Submitted : 6/30/2005
Category : Windows Operations
Compatibility : VB 6
This code has been accessed 7619 times.
Task : It is complete code for application monitoring,event capturing.
Declarations
Code
Function getcaption(hwnd As Long)
Dim tot As Long, str As String, cc As Long
tot = GetWindowTextLength(hwnd)
'Text1.Text = tot
str = String$(tot, 0)
a = GetWindowText(hwnd, str, (tot + 1))
If str = "" Then str = "<No Title>"
'List1.AddItem str & hwnd
'List2.AddItem hwnd
p = GetUserName(user_name, 50)
Call grid_display(str, hwnd, user_name)
getcaption = str
End Function
Private Sub Command1_Click()
'Text1.Text = Trim(user_name)
End Sub
Private Sub Form_Load()
'row_value = 9
'fg1.Rows = row_value
col_n = 1
row_n = 1
fg1.Col = 1
fg1.Row = 0
fg1.Text = "Application"
fg1.Col = 2
fg1.Text = "Window-Id"
fg1.Col = 3
fg1.Text = "Date"
fg1.Col = 4
fg1.Text = "Access Time"
fg1.Col = 5
fg1.Text = "Access Time"
fg1.Col = 5
fg1.Text = "User"
current = GetForegroundWindow
z = getcaption(current)
End Sub
Private Sub Timer1_Timer()
Dim hwnd As Long
hwnd = GetForegroundWindow
If hwnd <> current Then
current = hwnd
y = getcaption(hwnd)
End If
End Sub
Function grid_display(win_text As String, win_id As Long, user_name1 As String)
'fg1.Rows = row_value + 1
fg1.Col = col_n
fg1.Row = row_n
fg1.Text = win_text
fg1.Col = col_n - 1
fg1.Text = Val(fg1.Row)
fg1.Col = 2
fg1.Text = Val(win_id)
fg1.Col = 3
fg1.Text = Format$(Now, "dd/mm/yyyy")
fg1.Col = 4
fg1.Text = Time
fg1.Col = 5
fg1.Text = Trim(user_name1)
'col_n = col_n + 1
row_n = row_n + 1
End Function