Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get array of all windows of specific desktop #20

Open
phazei opened this issue Nov 16, 2022 · 2 comments
Open

Get array of all windows of specific desktop #20

phazei opened this issue Nov 16, 2022 · 2 comments

Comments

@phazei
Copy link

phazei commented Nov 16, 2022

I need to be able to get an array with the identifiers for all windows on a specific desktop in order to properly cascade them. Could also be useful to get all the windows of a desktop with filtering for title or application for finer control but that's beyond this request.

More Detail:
Win 11 is missing the ability to "CascadeWindows". In Win10 and prior you could just right click on the task bar and do it. Sometimes I have 8+ desktops with 5-10 windows each. Sometimes they cover each other up. There's still a DLL function that allows you to cascade windows though.

I found this thread here:
https://www.autohotkey.com/board/topic/80580-how-to-programmatically-tile-cascade-windows/
where a useful "WinArrange" method is created to easily manage windows in different ways. It takes an optional array of windows for the CascadeWindows function:
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-cascadewindows

WORD CascadeWindows(
  [in, optional] HWND       hwndParent,
  [in]           UINT       wHow,
  [in, optional] const RECT *lpRect,
  [in]           UINT       cKids,
  [in, optional] const HWND *lpKids
);

cKids is an array of windows. If it isn't used, it tiles the windows in every single desktop all at once with some weird layering results. So being able to get a specific list of windows for virtual desktops would be super helpful.

Thank you!

@phazei
Copy link
Author

phazei commented Nov 16, 2022

Ah, ok, so I just saw #8 so you thought about it before.

And I see https://github.com/FuPeiJiang/VD.ahk/blob/class_VD/other%20examples/list%20VD%20of%20all%20windows.ahk
So using that I guess I can filter with VD.getCurrentDesktopNum() as well as somehow to get only visible or non-minimized windows and use that as the array item. Hopefully that array can be used with the cKids array. Really I just found out about AutoHotKey a couple hours ago so it's a lot to figure out all at once. Thanks for this helper library!

Edit:
Also, the examples are great, but a description of what they specifically do would be super helpful :D

@phazei
Copy link
Author

phazei commented Nov 16, 2022

Got it working and made a repo for it
https://github.com/phazei/Win11AutoHotKeyFixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant