C#屏幕截图触发器不起作用

时间:2018-08-08 06:18:24

标签: c#

我正在尝试做一些非常具体的事情;本质上,这段代码的作用:

else if (cmd == "streams")
                {
                    Console.WriteLine("Hello, thank you for testing out the streams beta.\nBefore you start, there are some things you should know.\n First off, all screenshots are saved to your documents folder. They are named streams and streams_green.\nTo stop recording, close the software.");
                    Console.WriteLine("Please enter your monitors resolution (RECORD WITH YOUR GAME IN FULLSCREEN WINDOWED)");
                    Console.WriteLine("X:");
                    int xres = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Y:");
                    int yres = Convert.ToInt32(Console.ReadLine());
                    p.Send(maxfps);
                    Console.WriteLine("Thank you, recording now started.");
                    Bitmap memoryImage;
                    memoryImage = new Bitmap(xres, yres);
                    Size s = new Size(memoryImage.Width, memoryImage.Height);
                    Graphics memoryGraphics = Graphics.FromImage(memoryImage);
                    for (var i = 0; ; i++)
                    {
                        memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);
                        string str = "";
                        string str2 = "";
                        str = string.Format(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                        $@"\streams{i}.png");
                        str2 = string.Format(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                        $@"\streams_green{i}.png");
                        System.Threading.Thread.Sleep(2);
                        //Send spacebar would go here
                        p.Send(green);
                        memoryImage.Save(str);
                        System.Threading.Thread.Sleep(1);
                        p.Send(regular);
                        memoryImage.Save(str2);
                        System.Threading.Thread.Sleep(1);

                    }

是将dvar发送到游戏,获取屏幕截图,再获取另一个dvar,然后获取另一个屏幕截图ect。如您所见,“ p.Send(绿色)”和“常规”。但是,我有一个问题。我正在尝试将所有绿屏屏幕截图保存为streams_green,将常规屏幕截图保存为streams。当前正在正确保存所有文件,但是_green图像与常规文件相同,即使绿色截图的拍摄时所显示的帧与其之前的帧完全不同。谢谢。

1 个答案:

答案 0 :(得分:0)

根据代码,您的方法仅在memoryGraphics.CopyFromScreen(0, 0, 0, 0, s);行进行一次屏幕截图,然后通过memoryImage.Save将其保存在两个单独的文件中。如果实例green(在p.Send(green)行中)和实例regular(在p.Send(regular)行中)具有要保存的信息,则应将其更改为Bitmap,然后保存。