有没有办法检测在全屏模式下运行的程序?但是使用事件监视器。
我已经完成了很多其他代码,但它们都没有好用,所有这些代码都需要一些定时器或大量使用...
使用我意味着很多!!!这就是问题所在。
这是该计划的开始:
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
private static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
private static extern IntPtr GetShellWindow();
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowRect(IntPtr hwnd, out RECT rc);
这是在Timer中运行的函数:
//Detect if the current app is running in full screen
bool runningFullScreen = false;
RECT appBounds;
Rectangle screenBounds;
IntPtr hWnd;
//get the dimensions of the active window
hWnd = GetForegroundWindow();
if (hWnd!=null && !hWnd.Equals(IntPtr.Zero))
{
//Check we haven't picked up the desktop or the shell
if (!(hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)))
{
GetWindowRect(hWnd, out appBounds);
//determine if window is fullscreen
screenBounds = Screen.FromHandle(hWnd).Bounds;
if ((appBounds.Bottom - appBounds.Top) == screenBounds.Height && (appBounds.Right - appBounds.Left) == screenBounds.Width)
{
runningFullScreen = true;
}
}
}
这个问题是我需要使用Timer或bgWorker,这对它的工作来说并不是很好。