PyGetWindow


NamePyGetWindow JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/asweigart/pygetwindow
SummaryA simple, cross-platform module for obtaining GUI information on application's windows.
upload_time2020-10-04 02:12:50
maintainer
docs_urlNone
authorAl Sweigart
requires_python
licenseBSD
keywords gui window geometry resize minimize maximize close title
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PyGetWindow
===========

A simple, cross-platform module for obtaining GUI information on and controlling application's windows.


Still under development. Currently only the Windows platform is implemented. If you want to help contribute, please contact al@inventwithpython.com!


Install
-------

    pip install pygetwindow


Examples
--------

(For this example, I'm using Windows and opened the Notepad application, which has a title of "Untitled - Notepad". Most of the effects of these functions can't be seen in text.)

PyGetWindow has functions for obtaining ``Window`` objects from a place on the screen, from the window title, or just getting all windows. (``hWnd`` is specific to the Windows platform.)

    >>> import pygetwindow as gw
    >>> gw.getAllTitles()
    ('', 'C:\\WINDOWS\\system32\\cmd.exe - pipenv  shell - python', 'C:\\github\\PyGetWindow\\README.md • - Sublime Text', "asweigart/PyGetWindow: A simple, cross-platform module for obtaining GUI information on application's windows. - Google Chrome", 'Untitled - Notepad', 'C:\\Users\\Al\\Desktop\\xlibkey.py • - Sublime Text', 'https://tronche.com/gui/x/xlib/ - Google Chrome', 'Xlib Programming Manual: XGetWindowAttributes - Google Chrome', 'Generic Ubuntu Box [Running] - Oracle VM VirtualBox', 'Oracle VM VirtualBox Manager', 'Microsoft Edge', 'Microsoft Edge', 'Microsoft Edge', '', 'Microsoft Edge', 'Settings', 'Settings', 'Microsoft Store', 'Microsoft Store', '', '', 'Backup and Sync', 'Google Hangouts - asweigart@gmail.com', 'Downloads', '', '', 'Program Manager')
    >>> gw.getAllWindows()
    (Win32Window(hWnd=131318), Win32Window(hWnd=1050492), Win32Window(hWnd=67206), Win32Window(hWnd=66754), Win32Window(hWnd=264354), Win32Window(hWnd=329210), Win32Window(hWnd=1114374), Win32Window(hWnd=852550), Win32Window(hWnd=328358), Win32Window(hWnd=66998), Win32Window(hWnd=132508), Win32Window(hWnd=66964), Win32Window(hWnd=66882), Win32Window(hWnd=197282), Win32Window(hWnd=393880), Win32Window(hWnd=66810), Win32Window(hWnd=328466), Win32Window(hWnd=132332), Win32Window(hWnd=262904), Win32Window(hWnd=65962), Win32Window(hWnd=65956), Win32Window(hWnd=197522), Win32Window(hWnd=131944), Win32Window(hWnd=329334), Win32Window(hWnd=395034), Win32Window(hWnd=132928), Win32Window(hWnd=65882))
    >>> gw.getWindowsWithTitle('Untitled')
    (Win32Window(hWnd=264354),)
    >>> gw.getActiveWindow()
    Win32Window(hWnd=1050492)
    >>> gw.getActiveWindow().title
    'C:\\WINDOWS\\system32\\cmd.exe - pipenv  shell - python'
    >>> gw.getWindowsAt(10, 10)
    (Win32Window(hWnd=67206), Win32Window(hWnd=66754), Win32Window(hWnd=329210), Win32Window(hWnd=1114374), Win32Window(hWnd=852550), Win32Window(hWnd=132508), Win32Window(hWnd=66964), Win32Window(hWnd=66882), Win32Window(hWnd=197282), Win32Window(hWnd=393880), Win32Window(hWnd=66810), Win32Window(hWnd=328466), Win32Window(hWnd=395034), Win32Window(hWnd=132928), Win32Window(hWnd=65882))


``Window`` objects can be minimized/maximized/restored/activated/resized/moved/closed and also have attributes for their current position, size, and state.

    >>> notepadWindow = gw.getWindowsWithTitle('Untitled')[0]
    >>> notepadWindow.isMaximized
    False
    >>> notepadWindow.maximize()
    >>> notepadWindow.isMaximized
    True
    >>> notepadWindow.restore()
    >>> notepadWindow.minimize()
    >>> notepadWindow.restore()
    >>> notepadWindow.activate()
    >>> notepadWindow.resize(10, 10) # increase by 10, 10
    >>> notepadWindow.resizeTo(100, 100) # set size to 100x100
    >>> notepadWindow.move(10, 10) # move 10 pixels right and 10 down
    >>> notepadWindow.moveTo(10, 10) # move window to 10, 10
    >>> notepadWindow.size
    (132, 100)
    >>> notepadWindow.width
    132
    >>> notepadWindow.height
    100
    >>> notepadWindow.topleft
    (10, 10)
    >>> notepadWindow.top
    10
    >>> notepadWindow.left
    10
    >>> notepadWindow.bottomright
    (142, 110)
    >>> notepadWindow.close()
    >>>
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/asweigart/pygetwindow",
    "name": "PyGetWindow",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "gui window geometry resize minimize maximize close title",
    "author": "Al Sweigart",
    "author_email": "al@inventwithpython.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/70/c7a4f46dbf06048c6d57d9489b8e0f9c4c3d36b7479f03c5ca97eaa2541d/PyGetWindow-0.0.9.tar.gz",
    "platform": "",
    "description": "PyGetWindow\n===========\n\nA simple, cross-platform module for obtaining GUI information on and controlling application's windows.\n\n\nStill under development. Currently only the Windows platform is implemented. If you want to help contribute, please contact al@inventwithpython.com!\n\n\nInstall\n-------\n\n    pip install pygetwindow\n\n\nExamples\n--------\n\n(For this example, I'm using Windows and opened the Notepad application, which has a title of \"Untitled - Notepad\". Most of the effects of these functions can't be seen in text.)\n\nPyGetWindow has functions for obtaining ``Window`` objects from a place on the screen, from the window title, or just getting all windows. (``hWnd`` is specific to the Windows platform.)\n\n    >>> import pygetwindow as gw\n    >>> gw.getAllTitles()\n    ('', 'C:\\\\WINDOWS\\\\system32\\\\cmd.exe - pipenv  shell - python', 'C:\\\\github\\\\PyGetWindow\\\\README.md \u2022 - Sublime Text', \"asweigart/PyGetWindow: A simple, cross-platform module for obtaining GUI information on application's windows. - Google Chrome\", 'Untitled - Notepad', 'C:\\\\Users\\\\Al\\\\Desktop\\\\xlibkey.py \u2022 - Sublime Text', 'https://tronche.com/gui/x/xlib/ - Google Chrome', 'Xlib Programming Manual: XGetWindowAttributes - Google Chrome', 'Generic Ubuntu Box [Running] - Oracle VM VirtualBox', 'Oracle VM VirtualBox Manager', 'Microsoft Edge', 'Microsoft Edge', 'Microsoft Edge', '', 'Microsoft Edge', 'Settings', 'Settings', 'Microsoft Store', 'Microsoft Store', '', '', 'Backup and Sync', 'Google Hangouts - asweigart@gmail.com', 'Downloads', '', '', 'Program Manager')\n    >>> gw.getAllWindows()\n    (Win32Window(hWnd=131318), Win32Window(hWnd=1050492), Win32Window(hWnd=67206), Win32Window(hWnd=66754), Win32Window(hWnd=264354), Win32Window(hWnd=329210), Win32Window(hWnd=1114374), Win32Window(hWnd=852550), Win32Window(hWnd=328358), Win32Window(hWnd=66998), Win32Window(hWnd=132508), Win32Window(hWnd=66964), Win32Window(hWnd=66882), Win32Window(hWnd=197282), Win32Window(hWnd=393880), Win32Window(hWnd=66810), Win32Window(hWnd=328466), Win32Window(hWnd=132332), Win32Window(hWnd=262904), Win32Window(hWnd=65962), Win32Window(hWnd=65956), Win32Window(hWnd=197522), Win32Window(hWnd=131944), Win32Window(hWnd=329334), Win32Window(hWnd=395034), Win32Window(hWnd=132928), Win32Window(hWnd=65882))\n    >>> gw.getWindowsWithTitle('Untitled')\n    (Win32Window(hWnd=264354),)\n    >>> gw.getActiveWindow()\n    Win32Window(hWnd=1050492)\n    >>> gw.getActiveWindow().title\n    'C:\\\\WINDOWS\\\\system32\\\\cmd.exe - pipenv  shell - python'\n    >>> gw.getWindowsAt(10, 10)\n    (Win32Window(hWnd=67206), Win32Window(hWnd=66754), Win32Window(hWnd=329210), Win32Window(hWnd=1114374), Win32Window(hWnd=852550), Win32Window(hWnd=132508), Win32Window(hWnd=66964), Win32Window(hWnd=66882), Win32Window(hWnd=197282), Win32Window(hWnd=393880), Win32Window(hWnd=66810), Win32Window(hWnd=328466), Win32Window(hWnd=395034), Win32Window(hWnd=132928), Win32Window(hWnd=65882))\n\n\n``Window`` objects can be minimized/maximized/restored/activated/resized/moved/closed and also have attributes for their current position, size, and state.\n\n    >>> notepadWindow = gw.getWindowsWithTitle('Untitled')[0]\n    >>> notepadWindow.isMaximized\n    False\n    >>> notepadWindow.maximize()\n    >>> notepadWindow.isMaximized\n    True\n    >>> notepadWindow.restore()\n    >>> notepadWindow.minimize()\n    >>> notepadWindow.restore()\n    >>> notepadWindow.activate()\n    >>> notepadWindow.resize(10, 10) # increase by 10, 10\n    >>> notepadWindow.resizeTo(100, 100) # set size to 100x100\n    >>> notepadWindow.move(10, 10) # move 10 pixels right and 10 down\n    >>> notepadWindow.moveTo(10, 10) # move window to 10, 10\n    >>> notepadWindow.size\n    (132, 100)\n    >>> notepadWindow.width\n    132\n    >>> notepadWindow.height\n    100\n    >>> notepadWindow.topleft\n    (10, 10)\n    >>> notepadWindow.top\n    10\n    >>> notepadWindow.left\n    10\n    >>> notepadWindow.bottomright\n    (142, 110)\n    >>> notepadWindow.close()\n    >>>",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A simple, cross-platform module for obtaining GUI information on application's windows.",
    "version": "0.0.9",
    "split_keywords": [
        "gui",
        "window",
        "geometry",
        "resize",
        "minimize",
        "maximize",
        "close",
        "title"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3b64c7eaea8758390aab6f741d42346c",
                "sha256": "17894355e7d2b305cd832d717708384017c1698a90ce24f6f7fbf0242dd0a688"
            },
            "downloads": -1,
            "filename": "PyGetWindow-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "3b64c7eaea8758390aab6f741d42346c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9699,
            "upload_time": "2020-10-04T02:12:50",
            "upload_time_iso_8601": "2020-10-04T02:12:50.806764Z",
            "url": "https://files.pythonhosted.org/packages/e1/70/c7a4f46dbf06048c6d57d9489b8e0f9c4c3d36b7479f03c5ca97eaa2541d/PyGetWindow-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-04 02:12:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "asweigart",
    "github_project": "pygetwindow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "pygetwindow"
}
        
Elapsed time: 0.02122s