Skip to main content

Get window/process information with ctypes, no dependencies

Project description

Get window information with ctypes

pip install ctypes-window-info

This function utilizes the Windows API to retrieve information about windows.

Args:
    hwnd (int or None): The handle of the window for which to retrieve the text, defaults to None (all windows).

Returns:
    namedtuple: A named tuples with - pid title windowtext hwnd length tid status coords_client dim_client coords_win dim_win class_name path

Note:
    This function uses the `GetWindowTextW` function from the `user32` library to retrieve the window text.
    It is intended for use on Windows operating systems and relies on the ctypes library to interface with the Windows API.

Examples:
    from ctypes_window_info import get_window_infos

    get_window_infos()

    [[WindowInfo(pid=88, title='Base_PowerMessageWindow', windowtext='', hwnd=197614, length=1, tid=9668, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Base_PowerMessageWindow', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     WindowInfo(pid=88, title='Chrome_StatusTrayWindow', windowtext='', hwnd=197592, length=1, tid=9668, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Chrome_StatusTrayWindow', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     WindowInfo(pid=88, title='Chrome_SystemMessageWindow', windowtext='', hwnd=197600, length=1, tid=9668, status='invisible', coords_client=(0, 130, 0, 10), dim_client=(130, 10), coords_win=(0, 136, 0, 39), dim_win=(136, 39), class_name='Chrome_SystemMessageWindow', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     WindowInfo(pid=88, title='Chrome_WidgetWin_0', windowtext='', hwnd=197580, length=1, tid=9668, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Chrome_WidgetWin_0', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     WindowInfo(pid=88, title='Chrome_WidgetWin_0', windowtext='', hwnd=197606, length=1, tid=9668, status='invisible', coords_client=(0, 1424, 0, 728), dim_client=(1424, 728), coords_win=(182, 1622, 182, 949), dim_win=(1440, 767), class_name='Chrome_WidgetWin_0', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     WindowInfo(pid=88, title='Chrome_WidgetWin_1', windowtext='', hwnd=2492886, length=1, tid=9668, status='invisible', coords_client=(0, 64, 0, 64), dim_client=(64, 64), coords_win=(-1, 63, 1028, 1092), dim_win=(64, 64), class_name='Chrome_WidgetWin_1', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'),
     ....

     get_window_infos(197614)
     [WindowInfo(pid=88, title='Base_PowerMessageWindow', windowtext='', hwnd=197614, length=1, tid=9668, status='invisible', coords_client=(0, 0, 0, 0), dim_client=(0, 0), coords_win=(0, 0, 0, 0), dim_win=(0, 0), class_name='Base_PowerMessageWindow', path='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctypes_window_info-0.14.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

ctypes_window_info-0.14-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file ctypes_window_info-0.14.tar.gz.

File metadata

  • Download URL: ctypes_window_info-0.14.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for ctypes_window_info-0.14.tar.gz
Algorithm Hash digest
SHA256 36119bb240bed5226b23372e2502aa3524d12d66d62b3159ea9ccb12b5a3ff4a
MD5 653d280f1452c635a957756132b90cc1
BLAKE2b-256 2508026f3270df6f03ef720b65ab0ad2ae046791ec1cb3533f0b7498e719ca89

See more details on using hashes here.

Provenance

File details

Details for the file ctypes_window_info-0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for ctypes_window_info-0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 a7652652895a263d8be1ff4620bcb9a35fc9fbba28931c0a8e86fa46a428dc32
MD5 5f7cb81566ab5404d9aaa0ff2905c896
BLAKE2b-256 73ac7ca18219e14d57c27fa58a021be7a5ac5374ba8d7f1a8f65a8ff11494f87

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page