Kalmat / PyWinCtl

Cross-Platform module to get info on and control windows on screen
Other
191 stars 20 forks source link

getAllTitles: list of window titles sorted differently than on screen #4

Closed macdeport closed 2 years ago

macdeport commented 2 years ago

Yosemite: it occurs at least with Firefox, Thunderbird and Path Finder.

Windows are stacked object: the stack order is relevant. PyWinCtl's methods must therefore preserve this order for the user to use. For example, the last window on the stack is the one that has the focus.

Kalmat commented 2 years ago

Hey! These methods were never intended to take into account the windows/apps stacking. Never the less is a very good point. Some things to take into account:

I will look into it anyway.

macdeport commented 2 years ago

getAllWindows() and getAllTitles() output respects windows stacking within a given app, but not the app stacking. App order returned by Apple Script corresponds to when the apps were open (older-to-newer)

For a given application the question is solved. This is already a good point.

Last, but most important, I don't think it can be done using Apple Script.

Maybe useful to check the window index that AppleScript uses: you can access the different windows by "window index n".

Kalmat commented 2 years ago

Yes, window index is very useful for this, but it is related to the index within every app. So, every app will have a window 1, and so on. I couldn't find a similar value (index or attribute) for apps. I tried using Quartz.CGWindowListCopyWindowInfo(), but it doesn't return the windows in the screen stacking order either. I found several similar questions on stackoverflow, with no answer... Still searching, though

Thank you for your help to improve!

Kalmat commented 2 years ago

Hi again! Unfortunately, I was not able to find any method to return applications according to their stack order. I don't like to give up at all, so I will shamefully close this issue...

macdeport commented 2 years ago

@Kalmat Don't be sorry. It's me following it because I didn't realize in any way the difficulty in practice of such an "obvious" stack order. Note that the WM (Window Manager) necessarily maintains such an ordered list. Thanks for this project and the result already obtained.