阅读并响应屏幕上的匹配标准

发布于 2024-07-14 14:16:18 字数 201 浏览 3 评论 0 原文

我正在寻找为我的 Win32 系统开发一些东西,可以找到并响应特定的屏幕事件。 例如,当我的屏幕(屏幕的 30x30 像素部分)的位图范围 (100,100) 到 (130,130) 与提供的 30x30 像素基线匹配时,则执行特定操作。

谁能帮我开始做这个吗? 也许有一个框架可以让这变得更容易? 或者我可以使用的包? 或者甚至可能是第三方实用程序?

I'm looking to developing something for my Win32 system that can find and respond to particular screen events. For instance, when bitmap range (100,100) to (130,130) of my screen (a 30x30 pixel portion of the screen) matches a provided 30x30 pixel baseline, then do a certain action.

Can anyone get me started with this? Perhaps there's a framework that will make this easier? Or a package I can use? Or even perhaps a 3rd party utility?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦浮鱼 2024-07-21 14:16:18

您可以尝试获取桌面窗口 (GetDesktopWindow< /code>),然后获取它的设备上下文(GetWindowDC),然后创建兼容的内存设备上下文 (CreateCompatibleDC),从桌面 dc 创建兼容位图 (CreateCompatibleBitmap),在内存 dc 中选择它 (SelectObject),然后对您感兴趣的区域从桌面 DC 到内存 DC (BitBlt)。 完成这一切后别忘了清理。

哦,如果您在托管代码中执行此操作,则可以在 PInvoke.net 上找到所有这些 API。 您还需要使用 Imaging.CreateBitmapSourceFromHBitmap 将位图从本机位图复制到托管位图。

我凭记忆写下这一切; 它曾经在 XP 上运行,但我没有在 Vista 或 Win7 上尝试过。

编辑:在网络上快速搜索“.Net screen capture”会返回一些结果,包括这个,带有 C# 和 VB.Net 示例代码。

You can try getting the desktop window (GetDesktopWindow) and then getting a device context for it (GetWindowDC), then create a compatible in-memory device context (CreateCompatibleDC), create a compatible bitmap from the desktop dc (CreateCompatibleBitmap), select it in the in-memory dc (SelectObject) and then do bit-blitting fo the region you are interested from the desktop dc into the in-memory dc(BitBlt). Don't forget to cleanup after all this.

Oh, and if you are doing this in managed code, you can find all these APIs on PInvoke.net. You'll also need to use Imaging.CreateBitmapSourceFromHBitmap to copy the bitmap from the native bitmap into the managed bitmap.

I am writing all this from memory; it used to work on XP, but I have not tried it on Vista or Win7.

EDIT: A quick search on the web for ".Net screen capture" returns couple of hits, including this one with sample code in C# and VB.Net.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文