如何检测全屏应用程序是否正在Windows中运行?

问题描述 投票:1回答:2

像Messenger,如果用户在全屏模式下运行某些程序,例如wmplayer,则可以将其状态更改为“离开”。如果系统在全屏模式下运行某些内容,是否有任何相似的方式可以在JAVA中找到?

java windows fullscreen
2个回答
1
投票

AutoIt是功能强大的Windows GUI自动化工具,除其他功能外,还具有许多用于调查和与Windows交互的功能。我知道他们提供了多种与AutoIt功能进行外部交互的方式,可能值得研究:

http://www.autoitscript.com/autoit3/index.shtml


0
投票

使用JNA(https://mvnrepository.com/artifact/net.java.dev.jna/jna

 public static boolean isAppInFullScreen()
 {
        WinDef.HWND foregroundWindow = User32.INSTANCE.GetForegroundWindow();
        WinDef.RECT foregroundRectangle = new WinDef.RECT();
        WinDef.RECT desktopWindowRectangle = new WinDef.RECT();
        User32.INSTANCE.GetWindowRect( foregroundWindow, foregroundRectangle );
        WinDef.HWND desktopWindow = User32.INSTANCE.GetDesktopWindow();
        User32.INSTANCE.GetWindowRect( desktopWindow, desktopWindowRectangle );
        return foregroundRectangle.toString().equals( desktopWindowRectangle.toString() );
 }

如果Windows中有任何应用程序/程序以全屏模式运行,则返回true。甚至在F11模式下的浏览器也返回true。

© www.soinside.com 2019 - 2024. All rights reserved.