Public Class Form1
Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
Declare Function GetWindowText Lib "user32.dll" _
Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, _
ByVal cch As Int32) As Int32
Private Function FinestraAttiva() As String
Dim Stringa As String = New String(Chr(0), 100)
GetWindowText(GetForegroundWindow, Stringa, 100)
Stringa = Stringa.Substring(0, InStr(Stringa, Chr(0)) - 1)
Return Stringa
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.tmrRecorderApplication.Start()
Me.tmrScritturaFile.Start()
Me.Label4.Text = Date.Now
End Sub
Private Sub tmrRecorderApplication_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRecorderApplication.Tick
Dim a As String = Me.FinestraAttiva.ToString
Me.Label3.Text = a
End Sub
Private Sub Label3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.TextChanged
Dim a As String = Me.Label3.Text.ToString
Me.TextBox1.AppendText(" [*" & a + "*] ")
Me.TextBox1.AppendText(" ")
End Sub
Private Sub tmrScritturaFile_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrScritturaFile.Tick
Dim File As New IO.
StreamWriter(Application.
StartupPath & "\Recorder Application.txt")
File.
Write(Me.
TextBox1.
Text.
ToString)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TextBox1.Clear()
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
If Me.Visible = False Then
Me.Visible = True
Else
Me.Visible = False
End If
End Sub
End Class