在其他窗口上覆盖文本 - HUD

发布于 2024-08-07 20:53:02 字数 291 浏览 2 评论 0原文

我有兴趣编写一个覆盖小型平视显示器的应用程序(HUD)在 VB.NET 中的另一个应用程序上。有什么例子吗?

我需要枚举所有打开的窗口以找到我想要的窗口,然后在窗口的特定位置覆盖一些文本。如果用户移动该窗口,我的文本将需要跟随。 (我可能会一遍又一遍地循环绘制文本)。

编辑:没有人回答我原来的查询 - 我将 C# 添加到关键字中,看看该语言的专家是否有答案。

I am interested in writing an application that overlays a small heads up display (HUD) over another application, in VB.NET. What is an example of this?

I will need to enumerate all open windows to find the window that I want, and then overlay some text in a specific position on the window. If the user moves that window, my text will need to follow. (I will probably be painting the text in a loop over and over).

Edit: nobody answered my original query - I added C# to the keywords to see if any of gurus in that language might have an answer.

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

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

发布评论

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

评论(1

惟欲睡 2024-08-14 20:53:02

您可以使用 WinApi 枚举窗口。
你可以开始谷歌搜索

[DllImport("user32.dll")]
public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, ref WapiRect lpRect);

当你找到你的窗口并有它的句柄时,用类似的东西在它上面绘制是没有问题的

Graphics g = Graphics.FromHwnd(win.Handle);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 1000, 1000);

但是要覆盖... 一种可能的解决方案是创建自己的无边框表单(它甚至可以变得透明) )并将您的文字放在上面。然后只需将此特殊表格放在另一个应用程序之上即可。

You can use WinApi to enumerate windows.
You can start googling with

[DllImport("user32.dll")]
public static extern int EnumWindows(EnumWindowsProc ewp, int lParam);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowRect(IntPtr hWnd, ref WapiRect lpRect);

When you have found your window and has its handle, there is no problem to plot on it with something like

Graphics g = Graphics.FromHwnd(win.Handle);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 1000, 1000);

But to overlay... One possible solution is to create own border less form(it can be made even transparent) and place your text on it. Then just place this special form on top of another application.

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