TransWikia.com

how to get all applications/windows in the current workspace in the view of the user programmatically ( in python )

Unix & Linux Asked by user127167 on January 31, 2021

Lets say i have applications A, B, C in the current workspace. A and B are beside each other (assume Application A is on focus ) and C is not visible on the screen ( it may [minimized] or [not be minimized, but its not visible] ) . I would like the program to print A, B( and not C ).

I tried using the Wnck package, but I only managed to get the following:

  1. Application in focus: screen.get_active_window().

  2. All applications : screen.get_windows().

  3. All applications in active workspace which are not minimized:

active_workspace = screen.get_active_workspace()
all_windows = screen.get_windows()
for window in all_windows:
    if window.get_workspace() == active_workspace and not window.is_minimized():
        print(window.get_name()) # it prints `C` as well, if C is not minimized

But I am not able to get the application only in the view of the user, i.e. A and B.

There is also window.is_above() , window.is_visible_on_workspace(wspace) , window.is_below() functions which gives True, True and False for all windows, respectively.

for win in screen.get_windows():
    print(win.get_name(), win.is_visible_on_workspace(wspace), win.is_above(),win.is_below())

# this gives True, True, False for all windows ( which i don't understand )

TLDR :- Print all applications in the view of the user ( which is visible on the screen ), irrespective of whether it is on focus or not. if there exists a solution in c or c++, they are most welcome ( but preferably python )

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP