如何在.NET 中编写屏幕录像机?
有没有办法用C#制作屏幕录像机?如果是这样,有人知道我可以使用任何教程或有关该主题的任何信息吗?
Is there a way to make a screen recorder in C#? If so, does anybody know of any tutorials I could use or any information on the subject?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看一下这段 VB.NET 代码。
Take a look at this VB.NET code.
我从 Lucas McCoy 获取了 VB.net 代码并将其转换为 C#。
录制 5 秒并将 gif 保存到桌面。 PS:有时当最后一个屏幕截图仍然通过线程中止,然后流尝试读取它时,我会收到错误。
代码非常慢。
这些是我必须添加的参考:
I took the VB.net code from Lucas McCoy and turned it into C#.
This records for 5 seconds and saved the gif to desktop. PS: I get an error sometimes when the last screenshot is still aborting via the thread and then the stream tries to read it.
Very slow code.
These are references I had to add:
对于线程异常,您可以使用此代码来避免这种情况
,并将标志设置为 static private bool (全局),并将其代替 while 循环中的 true 值:
这就是如何避免资源上的线程重叠。我知道这不是主题,但我想分享这条信息,因为线程总是使调试变得令人讨厌。
问候,
法瓦兹
For the Thread Exception, you can avoid that with this code
and put the flag as static private bool (global) and put it instead of the true value in the while loop:
that how you can avoid threading overlap on resource. I know that is not the subject but I want to share this piece of info because threads always make the debugging nasty.
Regards,
Fawaz
我采用了 Parox 代码并对其进行了修复,以减少错误并更适合 C# 语言编译器。
作为一名 C# 程序员,我可以说代码抛出错误并不奇怪。某些部分甚至可能导致堆栈溢出或终止应用程序异常 - 但这就是我们在此问答中所处的领域;)
长时间录制可能会导致
Counter
溢出并覆盖从录制的第一秒和可能的其他问题,但在我看来,最好将其附加到其他人的线程中:I took Parox code and repair it to be less buggy and more proper for C# language compilers.
What I can say as a C# programmer there is no surprise that the code throws errors. Some parts could even lead to stack overflows or killing the app exceptions - but that's the domain where we are at this Q&A ;)
Still long time recording can lead to
Counter
overflow and overriding PNGs taken from the first seconds of recording and probably other issues but in my opinion enough better to be attached in the thread for others: