This
program prevents your system from getting locked even if it is left idle for
time greater than your screen saver time. It basically presses ‘down’
arrow key every minute.
Create a
Windows Forms Application and add a timer to the form.
public Form1()
{
InitializeComponent();
StartAction();
}
private void StartAction()
{
// the timer is
started and the form is minimized
// set the timer interval as per your
needs. I have set it to be 60000 milliseconds = 1 min
timer_keypress.Enabled = true;
this.WindowState
= FormWindowState.Minimized;
this.ShowInTaskbar
= false;
}
To add the
application to your system tray when minimized, add a notify icon from your
toolbox to the forms and set properties appropriately. I chose an icon and
changed the text property. By default this form will be in minimized state, as
I have added code to do so in my StartAction function.
Add context menu
from your toolbox to show menu when the system tray icon is right clicked.
Right click contextMenuStrip and choose Edit items to add your menu items.
Double click on the menu item to add a handler. I’ve added ‘Exit’ menu. Set
your notify icon’s contextmenustrip property.
private void exitToolStripMenuItem_Click(object sender, EventArgs
e)
{
StopAction();
}
private void StopAction()
{
// the timer is
stopped and the form is closed
timer_keypress.Enabled = false;
this.Close();
}
//
this event will be triggered every minute
private void timer_keypress_Tick(object
sender, EventArgs e)
{
SendKeys.SendWait("{DOWN}");
}
There are many
ways to do this, I found this one to be easy.
Here is the file -
KeyPress.exe (889 KB)