Skip to content

Commit f1dadc2

Browse files
committed
Minor cleanup
1 parent 12c5f4b commit f1dadc2

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

ActiveWindowLogger/frmMain.Designer.vb

Lines changed: 33 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ActiveWindowLogger/frmMain.vb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ Imports System.Data
33
Imports System.Data.OleDb
44

55
Public Class frmMain
6+
67
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
78
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" (ByVal hwnd As IntPtr, ByRef lpdwProcessID As Integer) As Integer
89
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hWnd As IntPtr, ByVal WinTitle As String, ByVal MaxLength As Integer) As Integer
910
Private Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Integer
1011

12+
' Set during app launch.
13+
' Used to track how long the app has been runnning.
1114
Dim AppLaunchTime As New Date
1215

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
1421

1522
' Get the Handle to the Current Foreground Window
1623
Dim hWnd As IntPtr = GetForegroundWindow()
@@ -62,13 +69,13 @@ Public Class frmMain
6269
newEntry.SubItems.Add(Format(Now, "yyyy/MM/dd HH:mm:ss"))
6370
txtWindowStatus.Text = "Started tracking active window"
6471

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"
6673

6774
End Sub
6875

6976
Private Sub chkStatus_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkStatus.CheckedChanged
7077
If chkStatus.Checked Then
71-
chkStatus.BackColor = Color.DarkGreen
78+
chkStatus.BackColor = Color.LimeGreen
7279
chkStatus.Text = vbCrLf + "Logging Active Windows" + vbCrLf + vbCrLf + "( click to pause )"
7380
tmrPoll.Enabled = True
7481
Else
@@ -83,10 +90,6 @@ Public Class frmMain
8390
AppLaunchTime = DateTime.UtcNow
8491
End Sub
8592

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-
9093
Private Sub lvEntries_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lvEntries.ItemChecked
9194
If (lvEntries.Items.Count <> lvEntries.CheckedItems.Count) And (lvEntries.CheckedItems.Count > 0) Then
9295
chkSelect.CheckState = CheckState.Indeterminate

0 commit comments

Comments
 (0)