.NET 等效的截图工具
我正在寻找与截图工具执行相同操作的 .NET 代码 - 捕获屏幕区域。 我相信它使用了钩子。想知道它如何突出显示所选片段会很有趣。
更新: 找到http://www.codeproject.com/KB/vb/Screen_Shot.aspx .尽管人们说它缺少一些正确编译的重要文件。
I'm looking for .NET code which performs the same as Snipping Tool - capturing a screen area.
I believe it uses hooks. Would be interesting to know how does it highlight the selected fragment.
Update:
Found http://www.codeproject.com/KB/vb/Screen_Shot.aspx . Though people say it's missing some important files for proper compilation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
截图工具效果在Windows窗体中实现并不困难。将新表单添加到您的项目中并将其命名为“SnippingTool”。使代码如下所示:
用法:
The snipping tool effect isn't difficult to implement in Windows Forms. Add a new form to your project and name it "SnippingTool". Make the code look like this:
Usage:
这是 @Hans 的修改版,它与多个显示器兼容,并且与 DPI 缩放配合良好(在 Windows 7 和 Windows 10 上测试)。
用法:
请注意,您需要一个辅助类来获取实际的显示器分辨率并避免 DPI 缩放问题。
这是代码:
这是完整的源代码
This is a modified @Hans's version that is compatible with multiple monitors and works well with DPI scaling (tested on Windows 7 and Windows 10).
Usage:
Note you need a helper class to get the actual monitor resolution and avoid problems with DPI scaling.
This is the code:
Here is the complete source code
它获取全屏屏幕截图,然后(可能)复制它,应用半透明效果并创建屏幕截图。显示它。当您单击并拖动时,它可以覆盖原始捕获中的相应区域。
您可以使用
CopyFromScreen()
或使用 GDI API。It takes a full-screen screenshot, then (probably) copies it, applies the translucent effect & displays it. When you click-drag it can then overlay the corresponding region from the original capture.
You can get a screenshot using
CopyFromScreen()
or using the GDI API.