Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Recorder Application - Form1.vb

Form1.vb

Caricato da: Progman-92
Scarica il programma completo

  1. Public Class Form1
  2.     Declare Function GetForegroundWindow Lib "user32.dll" () As Int32
  3.     Declare Function GetWindowText Lib "user32.dll" _
  4.     Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, _
  5.     ByVal cch As Int32) As Int32
  6.  
  7.     Private Function FinestraAttiva() As String
  8.         Dim Stringa As String = New String(Chr(0), 100)
  9.         GetWindowText(GetForegroundWindow, Stringa, 100)
  10.         Stringa = Stringa.Substring(0, InStr(Stringa, Chr(0)) - 1)
  11.         Return Stringa
  12.     End Function
  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14.         Me.tmrRecorderApplication.Start()
  15.         Me.tmrScritturaFile.Start()
  16.         Me.Label4.Text = Date.Now
  17.     End Sub
  18.  
  19.     Private Sub tmrRecorderApplication_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRecorderApplication.Tick
  20.         Dim a As String = Me.FinestraAttiva.ToString
  21.         Me.Label3.Text = a
  22.     End Sub
  23.  
  24.     Private Sub Label3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.TextChanged
  25.         Dim a As String = Me.Label3.Text.ToString
  26.         Me.TextBox1.AppendText(" [*" & a + "*] ")
  27.         Me.TextBox1.AppendText(" ")
  28.     End Sub
  29.  
  30.  
  31.     Private Sub tmrScritturaFile_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrScritturaFile.Tick
  32.         Dim File As New IO.StreamWriter(Application.StartupPath & "\Recorder Application.txt")
  33.         File.Write(Me.TextBox1.Text.ToString)
  34.         File.Close()
  35.  
  36.     End Sub
  37.  
  38.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  39.         Me.TextBox1.Clear()
  40.     End Sub
  41.  
  42.     Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
  43.         If Me.Visible = False Then
  44.             Me.Visible = True
  45.         Else
  46.             Me.Visible = False
  47.         End If
  48.     End Sub
  49. End Class