如何判断全屏应用程序是否正在运行? [英] How to tell if a full-screen application is running?

查看:83
本文介绍了如何判断全屏应用程序是否正在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在python中判断Linux上的全屏应用程序是否正在运行?我觉得使用Xlib可能有可能,但是我还没有找到方法.

编辑:全屏是指除了应用程序(例如全屏游戏)以外,整个屏幕都没有.

解决方案

找到了解决方案:

 导入Xlib.displayscreen = Xlib.display.Display().screen()root_win = screen.rootnum_of_fs = 0用于root_win.query_tree()._ data ['children']中的窗口:window_name = window.get_wm_name()宽度= window.get_geometry()._ data [宽度"]高度= window.get_geometry()._ data [高度"]如果width == screen.width_in_pixels和height == screen.height_in_pixels:num_of_fs + = 1打印num_of_fs 

这会打印出全屏窗口的数量,对我来说通常是一个.在玩全屏游戏时,其2.

Is it possible in python to tell if a full screen application on linux is running? I have a feeling it might be possible using Xlib but I haven't found a way.

EDIT: By full screen I mean the WHOLE screen nothing else but the application, such as a full-screen game.

解决方案

Found a solution:

import Xlib.display

screen = Xlib.display.Display().screen()
root_win = screen.root

num_of_fs = 0
for window in root_win.query_tree()._data['children']:
    window_name = window.get_wm_name()
    width = window.get_geometry()._data["width"]
    height = window.get_geometry()._data["height"]

    if width == screen.width_in_pixels and height == screen.height_in_pixels:
        num_of_fs += 1

print num_of_fs

This prints out the number of fullscreen windows which for me is normally one. When playing a full screen game its 2.

这篇关于如何判断全屏应用程序是否正在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆