Hi to you all. So I made an application that succesfully records my mouse movement to a log file. Now, I'd like to organise my application a bit more by adding Login section, so the records later could be easier to find. I made
this as a first tab page of my WPF app. After clicking "Save" button, I'd like to make it that user gets automatically moved to
second tab that provides you with record button, and your username you asigned.
My records tab would be a place where all of the records are shown and listed by username. Later on I'll made some kind of a graph to see which section is most active, but primary thing I want to succeed:
Auto jump to other tab after logging in, start recording as assigned username, all records saved and listed in "My records".
What I have tried:
I managed to record my mouse movement:
private static void recordData()
{
Point current_pos, prev_pos;
prev_pos.X = 0;
prev_pos.Y = 0;
do
{
Thread.Sleep(500);
if (GetCursorPos(out current_pos))
{
if ((current_pos.X != prev_pos.X) || (current_pos.Y != prev_pos.Y))
{
Console.WriteLine("({0},{1})", current_pos.X, current_pos.Y);
coords.Add(current_pos);
}
prev_pos.X = current_pos.X;
prev_pos.Y = current_pos.Y;
}
} while (record);
}
Record and
Stop button now work separately:
private void recordButton_click(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(recordData));
record = true;
if (!t.IsAlive)
{
t.Start();
}
recordButton.Enabled = false;
button2.Enabled = true;
}
private void stopButton_Click(object sender, EventArgs e)
{
record = false;
if (t.IsAlive)
{
t.Join();
}
string datum = DateTime.Now.ToString("MM-dd-yyyy_H_mm");
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string path = appPath + @"\logdata\" + datum + ".txt";
Console.WriteLine(path);
Directory.CreateDirectory(appPath + @"\logdata\");
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(path))
{
foreach (Point line in coords)
{
file.WriteLine(line.ToString());
}
}
recordButton.Enabled = true;
button2.Enabled = false;
}