static void Main(string[] args)
var guid = Guid.NewGuid().ToString("N");
for (int i = 1; i <= 10000; i++)
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
var directory = new DirectoryInfo($"第{i}次 {guid}");
string pptFile = GetPPT();
Console.WriteLine("启动文件: " + pptFile);
Console.WriteLine(@"第 " + i + " 次启动:");
p.StandardInput.WriteLine("\"" + pptFile + "\"");
p.StandardInput.AutoFlush = true;
Console.WriteLine(@"开始启动客户端");
keybd_event(116, 0, 0, 0);
for (int j = 1; j < 10; j++)
keybd_event(vbKeyDown, 0, 0, 0);
Console.WriteLine(@"开始翻页");
// 通过Graphics的CopyFromScreen方法把全屏图片的拷贝到我们定义好的一个和屏幕大小相同的空白图片中,
// 拷贝完成之后,CatchBmp就是全屏图片的拷贝了,然后指定为截图窗体背景图片就好了。
Bitmap CatchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
// 我们可以通过Graphics这个类在这个空白图片上画图
Graphics g = Graphics.FromImage(CatchBmp);
// 把屏幕图片拷贝到我们创建的空白图片 CatchBmp中
g.CopyFromScreen(new Point(0, 0), new Point(0, 0),
new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));
var file = new FileInfo(Path.Combine(directory.FullName, $"{j}.png"));
var fileStream = new FileStream(file.FullName, FileMode.Create, FileAccess.Write);
CatchBmp.Save(fileStream, ImageFormat.Png);
Console.WriteLine("保存截图" + file.FullName);
keybd_event(18, 0, 0, 0);
keybd_event(115, 0, 0, 0);
keybd_event(18, 0, 2, 0);
keybd_event(115, 0, 2, 0);
Console.WriteLine("干掉进程");
foreach (var temp in Process.GetProcesses())
if (temp.ProcessName.IndexOf("power", StringComparison.InvariantCultureIgnoreCase) >= 0)
private static string GetPPT()
var directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
var list = directory.GetFiles("*.pptx").ToList();
return list[_random.Next(list.Count)].FullName;
private static readonly Random _random = new Random();
[DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
public const byte vbKeyDown = 0x28; // DOWN ARROW 键