本文告诉大家一个可以使用的 C# 脚本,可以用来自动打开 PPT 文件,然后不断执行翻页。每次翻页都截图。翻页之后自动关闭 PPT 再次打开
最近发现给 Office 做的插件,会在一定翻页次数的时候,就 gg 了,所以我就写了这样的脚本,小伙伴可以拿去用
编译下面的代码,然后将几个需要测试的 PPTX 文件放在编译出来的程序相同文件夹,双击运行这个程序就可以进行测试
class Program
{
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";
//是否使用操作系统shell启动
p.StartInfo.UseShellExecute = false;
// 接受来自调用程序的输入信息
p.StartInfo.RedirectStandardInput = true;
//输出信息
p.StartInfo.RedirectStandardOutput = true;
// 输出错误
p.StartInfo.RedirectStandardError = true;
//不显示程序窗口
p.StartInfo.CreateNoWindow = true;
Thread.Sleep(2000);
var directory = new DirectoryInfo($"第{i}次 {guid}");
directory.Create();
string pptFile = GetPPT(