2424import win32api
2525import win32gui
2626
27- from ._main import BaseWindow , Re , _WatchDog , _findMonitorName
27+ from ._main import BaseWindow , Re , _WatchDog , _findMonitorName , _WINDATA , _WINDICT
2828from pywinbox import Size , Point , Rect , pointInBox
2929
3030# WARNING: Changes are not immediately applied, specially for hide/show (unmap/map)
@@ -231,7 +231,7 @@ def getAllAppsWindowsTitles() -> dict[str, List[str]]:
231231 return result
232232
233233
234- def getAllWindowsDict (tryToFilter : bool = False ) -> dict [str , int | dict [ str , int | dict [ str , str | dict [ str , int | Point | Size | str ]]] ]:
234+ def getAllWindowsDict (tryToFilter : bool = False ) -> dict [str , _WINDICT ]:
235235 """
236236 Get all visible apps and windows info
237237
@@ -241,7 +241,9 @@ def getAllWindowsDict(tryToFilter: bool = False) -> dict[str, int | dict[str, in
241241 Values:
242242 "pid": app PID
243243 "windows": subdictionary of all app windows
244- "title": subdictionary of window info
244+ Key: window title
245+
246+ Values:
245247 "id": window handle
246248 "display": display in which window is mostly visible
247249 "position": window position (x, y) within display
@@ -252,7 +254,7 @@ def getAllWindowsDict(tryToFilter: bool = False) -> dict[str, int | dict[str, in
252254 :return: python dictionary
253255 """
254256 process_list = _getAllApps (tryToFilter )
255- result : dict [str , int | dict [ str , int | dict [ str , str | dict [ str , int | Point | Size | str ]]] ] = {}
257+ result : dict [str , _WINDICT ] = {}
256258 for win in getAllWindows ():
257259 winId = win .getHandle ()
258260 pID = win32process .GetWindowThreadProcessId (winId )
@@ -265,18 +267,17 @@ def getAllWindowsDict(tryToFilter: bool = False) -> dict[str, int | dict[str, in
265267 status = 1
266268 elif win .isMaximized :
267269 status = 2
268- winDict = {
270+ pos = win .position
271+ size = win .size
272+ winDict : _WINDATA = {
269273 "id" : winId ,
270274 "display" : win .getDisplay (),
271- "position" : win . position ,
272- "size" : win . size ,
275+ "position" : ( pos . x , pos . y ) ,
276+ "size" : ( size . width , size . height ) ,
273277 "status" : status
274278 }
275279 if appName not in result .keys ():
276- result [appName ] = {}
277- result [appName ]["pìd" ] = appPID
278- if "windows" not in result [appName ].keys ():
279- result [appName ]["windows" ] = {}
280+ result [appName ] = {"pid" : appPID , "windows" : {}}
280281 result [appName ]["windows" ][win .title ] = winDict
281282 break
282283 return result
0 commit comments