Skip to content

Commit 43e816f

Browse files
authored
Update README.md
1 parent 7c92d0a commit 43e816f

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,51 @@ A clean, simple, and tiny library to detect user input like Keyboard and Mouse.
66
You can track the activity of the user using mouse and keyboard activity. This will track the last activity of the mouse and keyboard since last used using timeframe.
77

88
## How to Use it?
9+
10+
First, you need to add a reference of the **HmtInput.dll** library to your project which is present in this location `\bin\Debug\netstandard2.0\HmtInput.dll`
11+
12+
Then create a new class of your own and start by referring to different methods from the `HmtInput.dll` library.
13+
```
14+
using HmtInput;
15+
using System;
16+
using System.Windows.Forms;
17+
public class User
18+
{
19+
private System.Windows.Forms.Timer timer;
20+
private InputSources LastInput;
21+
22+
public User()
23+
{
24+
LastInput = new InputSources();
25+
this.timer = new System.Windows.Forms.Timer();
26+
this.timer.Interval = new TimeSpan(0, 0, 0, 0, 100).Milliseconds;
27+
this.timer.Tick += timer_Tick;
28+
this.timer.Start();
29+
}
30+
31+
private void timer_Tick(object sender, EventArgs e)
32+
{
33+
TimeSpan time = DateTime.Now.AddMinutes(1) - this.LastInput.GetLastInputTime();
34+
if (time.Minutes > 1)
35+
{
36+
this.timer.Stop();
37+
var result = MessageBox.Show("Are you Active?", "Checkpoint", MessageBoxButtions.YesNo, MessageBoxIcon.Question);
38+
if (result == DialogResult.No)
39+
{
40+
/* Do something big here */
41+
return;
42+
}
43+
this.timer.Start();
44+
}
45+
}
46+
}
47+
```
48+
In the above code, an event `timer_Tick` is activated from the class constructor. Its interval is set to `0.1 Sec`. This means the timer will check the activity of the mouse or keyboard after every `0.1 Sec`.
49+
50+
You can set the duration in the if condition from `1 Min` to any as you require.
51+
52+
After completing this code, create an object of this class like `User` in this example to the main form or anywhere else in your code to start tracking.
53+
54+
We hope this will be helpful to you.
55+
56+
Have any issues? Raise an [Issue](https://github.com/HumansMetaTech/HmtInput/issues)

0 commit comments

Comments
 (0)