@@ -3,14 +3,21 @@ Imports System.Data
3
3
Imports System.Data.OleDb
4
4
5
5
Public Class frmMain
6
+
6
7
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
7
8
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" ( ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer ) As Integer
8
9
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" ( ByVal hWnd As IntPtr, ByVal WinTitle As String , ByVal MaxLength As Integer ) As Integer
9
10
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" ( ByVal hwnd As Long ) As Integer
10
11
12
+ ' Set during app launch.
13
+ ' Used to track how long the app has been runnning.
11
14
Dim AppLaunchTime As New Date
12
15
13
- Private Sub Timer1_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPoll.Tick
16
+ Private Sub tmrMinute_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMinute.Tick
17
+ lblStatus.Text = lvEntries.Items.Count.ToString + " windows" + vbCrLf + "since last " + DateDiff(DateInterval.Minute, AppLaunchTime, DateTime.UtcNow).ToString + " minutes"
18
+ End Sub
19
+
20
+ Private Sub tmrPoll_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPoll.Tick
14
21
15
22
' Get the Handle to the Current Foreground Window
16
23
Dim hWnd As IntPtr = GetForegroundWindow()
@@ -62,13 +69,13 @@ Public Class frmMain
62
69
newEntry.SubItems.Add(Format(Now, "yyyy/MM/dd HH:mm:ss" ))
63
70
txtWindowStatus.Text = "Started tracking active window"
64
71
65
- lblStatus.Text = lvEntries.Items.Count.ToString + " windows" + vbCrLf + "since " + DateDiff(DateInterval.Minute, AppLaunchTime, DateTime.UtcNow).ToString + " minutes"
72
+ lblStatus.Text = lvEntries.Items.Count.ToString + " windows" + vbCrLf + "since last " + DateDiff(DateInterval.Minute, AppLaunchTime, DateTime.UtcNow).ToString + " minutes"
66
73
67
74
End Sub
68
75
69
76
Private Sub chkStatus_CheckedChanged( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkStatus.CheckedChanged
70
77
If chkStatus.Checked Then
71
- chkStatus.BackColor = Color.DarkGreen
78
+ chkStatus.BackColor = Color.LimeGreen
72
79
chkStatus.Text = vbCrLf + "Logging Active Windows" + vbCrLf + vbCrLf + "( click to pause )"
73
80
tmrPoll.Enabled = True
74
81
Else
@@ -83,10 +90,6 @@ Public Class frmMain
83
90
AppLaunchTime = DateTime.UtcNow
84
91
End Sub
85
92
86
- Private Sub tmrMinute_Tick( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMinute.Tick
87
- lblStatus.Text = lvEntries.Items.Count.ToString + " windows" + vbCrLf + "since " + DateDiff(DateInterval.Minute, AppLaunchTime, DateTime.UtcNow).ToString + " minutes"
88
- End Sub
89
-
90
93
Private Sub lvEntries_ItemChecked( ByVal sender As Object , ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lvEntries.ItemChecked
91
94
If (lvEntries.Items.Count <> lvEntries.CheckedItems.Count) And (lvEntries.CheckedItems.Count > 0 ) Then
92
95
chkSelect.CheckState = CheckState.Indeterminate
0 commit comments