[C#]Keep from losing your work with this simple "quick saver"

Discussion in 'C#' started by begallegal1, Dec 21, 2013.

  1. begallegal1

    begallegal1 Medicine Man Lifetime Gold TeamXPG
    55/94

    3,694
    3,131
    235
    Oct 31, 2011
    In a Field of Green
    Console:
    Xbox
    Hello all, I'm sure we have all been in the situation where we have lost work due to one type of shutdown or another before you could (or remember to) save your last changes in your work, well here is an ultra simple solution you can make in minutes that works with every windows program I tried that saves using the "CTRL + S" keys

    so we need a small form with 2 buttons for on and off, a scroll bar that counts from 1-60, and a timer set to disabled by default and at 1000m/s interval. The notes in the code should explain the rest ;)

    this is mine running showing the debug output in the code as I changed the interval a few times
    [​IMG]

    using System;
    using System.Diagnostics;
    using System.Windows.Forms;

    namespace QuickSaver
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void onBtn_Click(object sender, EventArgs e)
    {
    //Starts save timer

    saveTimer.Start();
    }

    private void offBtn_Click(object sender, EventArgs e)
    {
    //Stops save timer

    saveTimer.Stop();
    }

    private void saveTimer_Tick(object sender, EventArgs e)
    {
    //Sends the keys CTRL+S to save our work
    //in most windows applications

    SendKeys.Send("^s");

    //Debug Print lines to show us the keys are sent at the specified //interval(per timer tick)

    Debug.Print("Sent Keys" + "^s");
    Debug.Print("Timer interval is: " + saveTimer.Interval + " m/s");
    }

    private void saveIntervalBar_Scroll(object sender, EventArgs e)
    {
    //if scroll bar value is changed
    //we adjust the timer interval to "trackbar value x 1000"

    saveTimer.Interval = saveIntervalBar.Value * 1000;

    //timer value is counted in m/s
    }
    }
    }
    When on, whatever app has focus on your screen will save at your specified interval..
    No more lost work! :D Enjoy and happy coding!

    :begal:
     

    Attached Files:

  2. Froody

    Froody Developer XPG Developer Lifetime Gold
    55/94

    151
    145
    55
    Jun 10, 2013
    Scotland
    Console:
    Xbox
    Thanks for this Begal, I lose work on most of my projects so this should help!
     

Share This Page