{"id":25450873,"url":"https://github.com/hansalemaos/appshwnd","last_synced_at":"2025-05-16T09:36:38.904Z","repository":{"id":191162324,"uuid":"637583412","full_name":"hansalemaos/appshwnd","owner":"hansalemaos","description":"includes functions for finding windows based on various attributes, getting information about visible and invisible windows, and making window names unique","archived":false,"fork":false,"pushed_at":"2023-05-10T06:01:57.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T21:09:14.113Z","etag":null,"topics":["ctypes","findwindows","hwnd","pyautogui","pywin32"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/appshwnd/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-08T01:20:05.000Z","updated_at":"2023-05-08T01:21:50.000Z","dependencies_parsed_at":"2023-08-28T13:28:33.095Z","dependency_job_id":"79b60b2d-83f0-42c1-a25a-c418c3b1393d","html_url":"https://github.com/hansalemaos/appshwnd","commit_stats":null,"previous_names":["hansalemaos/appshwnd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fappshwnd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fappshwnd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fappshwnd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fappshwnd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/appshwnd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254505222,"owners_count":22082154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ctypes","findwindows","hwnd","pyautogui","pywin32"],"created_at":"2025-02-17T22:16:39.360Z","updated_at":"2025-05-16T09:36:38.870Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# appshwnd\r\n\r\nThis module provides utilities for finding and manipulating windows in Windows OS. It includes functions for finding windows based on various attributes,  getting information about visible and invisible windows, and making window names unique (e.g. With FFmpeg, you can record a window, but you have to pass the title of the Window which causes problems if there are duplicates. )\r\n\r\n## pip install appshwnd\r\n\r\n\r\n#### ### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n\r\n### Functions\r\n```python\r\nFUNCTIONS\r\n    find_window_and_make_best_window_unique(searchdict: dict, timeout: float | int = 5, make_unique: bool = True, *args, **kwargs)\r\n            Search for the window that matches the given criteria dictionary and makes its window title unique (if desired).\r\n        Args:\r\n            searchdict (dict): The dictionary that contains the search criteria for the window.\r\n            timeout (float or int): The time in seconds to wait for making the window unique. Defaults to 5.\r\n            make_unique (bool): Whether to make the window unique or not. Defaults to True.\r\n            *args: Passed to re.search .\r\n            **kwargs: Passed to re.search\r\n        Returns:\r\n            A tuple of best windows, best window, hwnd, start window text, updated window text, and revert name function.\r\n    \r\n    get_invisible_and_visible_windows()\r\n            Get information about both visible and invisible windows.\r\n        Args:\r\n            None\r\n        Returns:\r\n            A list of WindowInfo objects for both visible and invisible windows.\r\n    \r\n    get_invisible_windows()\r\n            Get information about invisible windows only.\r\n        Args:\r\n            None\r\n        Returns:\r\n            A list of WindowInfo objects for invisible windows only.\r\n    \r\n    get_visible_windows()\r\n            Get information about visible windows only.\r\n        Args:\r\n            None\r\n        Returns:\r\n            A list of WindowInfo objects for visible windows only.\r\n    \r\n    time(...)\r\n        time() -\u003e floating point number\r\n        \r\n        Return the current time in seconds since the Epoch.\r\n        Fractions of a second may be present if the system clock provides them.\r\n\r\n\r\n\r\n# A dictionary that contains all possible search criteria for finding a window. \r\n# You can pass as many attributes as you want. The window with the most matches wins. \r\nsearchdict = {\r\n    \"pid\": 1004,\r\n    \"pid_re\": \"^1.*\",\r\n    \"title\": \"IME\",\r\n    \"title_re\": \"IM?E\",\r\n    \"windowtext\": \"Default IME\",\r\n    \"windowtext_re\": r\"Default\\s*IME\",\r\n    \"hwnd\": 197666,\r\n    \"hwnd_re\": r\"\\d+\",\r\n    \"length\": 12,\r\n    \"length_re\": \"[0-9]+\",\r\n    \"tid\": 6636,\r\n    \"tid_re\": r\"6\\d+36\",\r\n    \"status\": \"invisible\",\r\n    \"status_re\": \"(?:in)?visible\",\r\n    \"coords_client\": (0, 0, 0, 0),\r\n    \"coords_client_re\": r\"\\([\\d,\\s]+\\)\",\r\n    \"dim_client\": (0, 0),\r\n    \"dim_client_re\": \"(1?0, 0)\",\r\n    \"coords_win\": (0, 0, 0, 0),\r\n    \"coords_win_re\": r\"\\)$\",\r\n    \"dim_win\": (0, 0),\r\n    \"dim_win_re\": \"(1?0, 0)\",\r\n    \"class_name\": \"IME\",\r\n    \"class_name_re\": \"I?ME$\",\r\n    \"path\": \"C:\\\\Windows\\\\ImmersiveControlPanel\\\\SystemSettings.exe\",\r\n    \"path_re\": \"SystemSettings.exe\",\r\n}\r\n\r\nfrom appshwnd import ( find_window_and_make_best_window_unique,\r\n get_invisible_and_visible_windows,\r\n get_invisible_windows,\r\n get_visible_windows,\r\n get_window_infos,)\r\n \r\n \r\n# Find the window without changing the window title \r\n(\r\n    bestwindows,  # most matches = first place\r\n    bestwindow,  # WindowInfo object\r\n    hwnd,  # 132762\r\n    startwindowtext,  # 'Default IME'\r\n    updatedwindowtext,  # 'Default IME' (no difference, because of make_unique=False)\r\n    revertnamefunction,  # restore the original name\r\n) = find_window_and_make_best_window_unique(\r\n    searchdict, timeout=5, make_unique=False, flags=re.I\r\n)\r\n\r\n# Example search for Notepad \r\n\r\n\r\nget_visible_windows()\r\n....\r\nWindowInfo(pid=8896, title='Notepad', windowtext='*Untitled - Notepad', hwnd=2034552, length=20, tid=2772, status='visible', coords_client=(0, 877, 0, 675), dim_client=(877, 675), coords_win=(745, 1638, 324, 1058), dim_win=(893, 734), class_name='Notepad', path='C:\\\\Windows\\\\System32\\\\notepad.exe'),\r\n....\r\nWindowInfo(pid=16852, title='Notepad', windowtext='*Untitled - Notepad', hwnd=657206, length=20, tid=16876, status='visible', coords_client=(0, 877, 0, 675), dim_client=(877, 675), coords_win=(475, 1368, 219, 953), dim_win=(893, 734), class_name='Notepad', path='C:\\\\Windows\\\\System32\\\\notepad.exe')]\r\n....\r\n\r\n\r\nsearchdict = {\r\n    \"title\": \"Notepad\",\r\n    \"windowtext_re\": r\"\\*+\",\r\n    'path_re': '.*notepad.exe.*'\r\n}\r\n\r\n# Find the window and make it unique\r\n(\r\n    bestwindows,  # most matches = first place\r\n    bestwindow,  # WindowInfo object\r\n    hwnd,  # window handle\r\n    startwindowtext,  # current window text\r\n    updatedwindowtext,  # updated window text\r\n    revertnamefunction,  # function to restore the original window text\r\n) = find_window_and_make_best_window_unique(\r\n    searchdict, timeout=5, make_unique=True, flags=re.I\r\n)\r\n\r\n# Example of restoring the original window text\r\nstartwindowtext  # '*Untitled - Notepad'\r\nupdatedwindowtext  # '*Untitled - Notepad ' (notice the space at the end - this window title is now unique)\r\nrevertnamefunction()  # Restore the old name\r\nstartwindowtext  # '*Untitled - Notepad'\r\nupdatedwindowtext  # '*Untitled - Notepad'\r\n\r\nAn example with FFmpeg (to make sure that you are recording the right window)\r\n1) Make the window title unique \r\n2) Start FFmpeg in a subprocess (Popen)\r\n3) After 2 seconds, you can change the name back: revertnamefunction()\r\n\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fappshwnd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Fappshwnd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fappshwnd/lists"}