-
Hi, for one of my project, I need to retreive hWnd. I want to show to the end user a window pop up with all active windows grouped by apps. I create this small script for this purpose :
this work, except that by adding Have tried several solution, no one quickest. Do you have any idea on how to improve that ? and thanks for this great module !! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Hi! Thank you for your interest in this module! First off, sorry for my late reply. I was trying to figure out how to properly manage your request. To be honest, I don't like mixing titles and names together with id's... On the other hand, you're totally right. Still not sure what could be the best for all cases, but right now I'm considering to build a method which returns a dictionary including all windows info (app name and pid, window id, title, position, etc.)... If it is not too demanding (this is what I have to check in all three platforms), may be this a more general solution for other future use cases including yours. Please, let me think and test the best solution. If you have any idea, it's welcome! |
Beta Was this translation helpful? Give feedback.
-
Sorry, I tested your code today... the time it takes is not acceptable at all!!! I will work in a new version. I think, by now, that the best solution is to build a dict containing all info. In the mean time, please use this code as a workaround (you are on Windows, right? Or do you need a multi-platform solution? If so, please let me know):
It returns a list of other lists each containing app name, window title and window id. It takes around 0.2 seconds in my system (the dict will take a bit longer, but it will contain more info). Note that Thank you again! |
Beta Was this translation helpful? Give feedback.
-
Hi! I have uploaded a new version to PyPi (v0.4.01) which includes Whenever you have time, please check it and let me know if it works in your case. Thanks for pointing out this issue and your help! |
Beta Was this translation helpful? Give feedback.
-
Hi, this works, great job, thanks a lot. Just one remark: to be "Json friendly", value for 'Point' and 'size' need to be reviewed (put ' or made it serializable). ` @staticmethod
` I will close this one as complete and thanks again. |
Beta Was this translation helpful? Give feedback.
-
So happy to hear that! Regarding Point and Size objects, you're right... Inside a dictionary perhaps it's better to stick to standard types (tuple[int, int]). I will change that in next version. In the mean time, just for your info, they are a NamedTuple classes:
So you can use them just importing them from PyWinCtl:
You can also serialize them in a more simple way by using this:
Thank you! |
Beta Was this translation helpful? Give feedback.
Hi! I have uploaded a new version to PyPi (v0.4.01) which includes
getAllWindowsDict()
function.Whenever you have time, please check it and let me know if it works in your case.
Thanks for pointing out this issue and your help!