METADATA 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. Metadata-Version: 2.4
  2. Name: PyGetWindow
  3. Version: 0.0.9
  4. Summary: A simple, cross-platform module for obtaining GUI information on application's windows.
  5. Home-page: https://github.com/asweigart/pygetwindow
  6. Author: Al Sweigart
  7. Author-email: al@inventwithpython.com
  8. License: BSD
  9. Keywords: gui window geometry resize minimize maximize close title
  10. Classifier: Development Status :: 4 - Beta
  11. Classifier: Environment :: Win32 (MS Windows)
  12. Classifier: Environment :: X11 Applications
  13. Classifier: Environment :: MacOS X
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: BSD License
  16. Classifier: Operating System :: OS Independent
  17. Classifier: Programming Language :: Python
  18. Classifier: Programming Language :: Python :: 2
  19. Classifier: Programming Language :: Python :: 2.7
  20. Classifier: Programming Language :: Python :: 3
  21. Classifier: Programming Language :: Python :: 3.4
  22. Classifier: Programming Language :: Python :: 3.5
  23. Classifier: Programming Language :: Python :: 3.6
  24. Classifier: Programming Language :: Python :: 3.7
  25. Description-Content-Type: text/markdown
  26. Requires-Dist: pyrect
  27. Dynamic: author
  28. Dynamic: author-email
  29. Dynamic: classifier
  30. Dynamic: description
  31. Dynamic: description-content-type
  32. Dynamic: home-page
  33. Dynamic: keywords
  34. Dynamic: license
  35. Dynamic: requires-dist
  36. Dynamic: summary
  37. PyGetWindow
  38. ===========
  39. A simple, cross-platform module for obtaining GUI information on and controlling application's windows.
  40. Still under development. Currently only the Windows platform is implemented. If you want to help contribute, please contact al@inventwithpython.com!
  41. Install
  42. -------
  43. pip install pygetwindow
  44. Examples
  45. --------
  46. (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.)
  47. 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.)
  48. >>> import pygetwindow as gw
  49. >>> gw.getAllTitles()
  50. ('', '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')
  51. >>> gw.getAllWindows()
  52. (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))
  53. >>> gw.getWindowsWithTitle('Untitled')
  54. (Win32Window(hWnd=264354),)
  55. >>> gw.getActiveWindow()
  56. Win32Window(hWnd=1050492)
  57. >>> gw.getActiveWindow().title
  58. 'C:\\WINDOWS\\system32\\cmd.exe - pipenv shell - python'
  59. >>> gw.getWindowsAt(10, 10)
  60. (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))
  61. ``Window`` objects can be minimized/maximized/restored/activated/resized/moved/closed and also have attributes for their current position, size, and state.
  62. >>> notepadWindow = gw.getWindowsWithTitle('Untitled')[0]
  63. >>> notepadWindow.isMaximized
  64. False
  65. >>> notepadWindow.maximize()
  66. >>> notepadWindow.isMaximized
  67. True
  68. >>> notepadWindow.restore()
  69. >>> notepadWindow.minimize()
  70. >>> notepadWindow.restore()
  71. >>> notepadWindow.activate()
  72. >>> notepadWindow.resize(10, 10) # increase by 10, 10
  73. >>> notepadWindow.resizeTo(100, 100) # set size to 100x100
  74. >>> notepadWindow.move(10, 10) # move 10 pixels right and 10 down
  75. >>> notepadWindow.moveTo(10, 10) # move window to 10, 10
  76. >>> notepadWindow.size
  77. (132, 100)
  78. >>> notepadWindow.width
  79. 132
  80. >>> notepadWindow.height
  81. 100
  82. >>> notepadWindow.topleft
  83. (10, 10)
  84. >>> notepadWindow.top
  85. 10
  86. >>> notepadWindow.left
  87. 10
  88. >>> notepadWindow.bottomright
  89. (142, 110)
  90. >>> notepadWindow.close()
  91. >>>