有没有一种方法可以让控制台应用程序出现在其他进程上



我目前正在制作一个自定义的十字光标控制台应用程序,并试图弄清楚如何使该应用程序显示在游戏屏幕和其他进程上,此外还可以用热键隐藏它。我的问题是,我似乎不知道如何使应用程序显示在其他窗口上。

我发现了

首先导入所需的依赖项

然后将以下代码插入您的主类

using System.Diagnostics;
using System.Runtime.InteropServices;
static void Main(string[] args)
{
IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle;
SetWindowPos(hWnd,
new IntPtr(HWND_TOPMOST),
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE);

}

最新更新