Within most of the organization, there is a default setting that after a few minutes have escaped, the system gets locked itself, if system is left unattended. Well to prevent this i have written a small utility (windows application) which periodically sends user input to the system, making it to believe that some mouse movement has been made and thus stopping the system from getting locked.
Here we would be calling SendInput function within user32.dll
The SendInput function synthesizes keystrokes, mouse motions, and button clicks and that is what we need.
http://msdn.microsoft.com/en-us/library/ms646310.aspx
This is useful in case we are giving presentation or else reading some documents …
Following is the code for the same
1) Create a new windows application in C#
2) Add a button named btn_Unlock to it and a timer control named timer1.
3) Set enabled to false and interval to 120000 for timer control.
4) Put the following code to your form class
public partial class frmKU : Form
{
public
frmKU()
{
InitializeComponent();
}
[DllImport(“User32.dll”, SetLastError = true)]
public static extern int SendInput(int
nInputs, ref INPUT
pInputs, int cbSize);
public struct INPUT
{
public
int type;
public
MOUSEINPUT mi;
}
public struct MOUSEINPUT
{
public
int dx;
public
int dy;
public
int mouseData;
public
int dwFlags;
public
int time;
public
int dwExtraInfo;
}
// Call the
API
int
resSendInput;
private
void btnUnlock_Click(object
sender, EventArgs e)
{
timer1.Enabled = true;
INPUT
input = new INPUT();
resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));
}
private
void timer1_Tick(object
sender, EventArgs e)
{
INPUT
input = new INPUT();
resSendInput = SendInput(5, ref input, Marshal.SizeOf(input));
}
}
Bye …