Skip to content

Instantly share code, notes, and snippets.

@juanplopes
Created October 1, 2010 16:14
Show Gist options
  • Save juanplopes/606419 to your computer and use it in GitHub Desktop.
Save juanplopes/606419 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace ConsoleApplication4
{
public static class Program
{
static void DoWait() { Thread.Sleep(5000); }
static int[] holidays = new int[] { 11, 12 };
static int[] startHours = new[] { 9, 9, 9, 10, 10, 11 };
static int[] endHours = new[] { 17, 18, 18, 19, 19, 19, 20 };
static int[] minutes = new[] { 0, 10, 15, 20, 30, 45, 50 };
static int[] lunchHours = new[] { 1 };
static int[] lunchMinutes = new[] { 0, 30, 50 };
static Random random = new Random();
static void Main(string[] args)
{
DoWait();
for (int i = 13; i <= 14; i++)
{
var date = new DateTime(2010, 10, i);
if (holidays.Contains(i) || date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday) continue;
SendKeys.SendWait(date.ToString("yyyy-MM-dd"));
SendKeys.SendWait("{tab}{tab}");
random.DoHours(startHours, minutes);
random.DoHours(endHours, minutes);
random.DoHours(lunchHours, lunchMinutes);
SendKeys.SendWait("{tab}{enter}");
DoWait();
SendKeys.SendWait("+{tab}");
}
}
static void DoHours(this Random random, int[] hours, int[] minutes)
{
SendKeys.SendWait(random.Choose(hours).ToString("00"));
SendKeys.SendWait("{tab}");
SendKeys.SendWait(random.Choose(minutes).ToString("00"));
SendKeys.SendWait("{tab}");
}
static int Choose(this Random r, int[] values)
{
return values[r.Next(values.Length)];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment