Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pygetwindow help
#1
>>> import pyautogui as pag
>>> import pygetwindow as gw
>>> import os
>>> pag.pause = 2
>>> pag.FAILSAFE = True
>>> os.startfile(r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Assessment and Planning Toolkit\Microsoft Assessment and Planning Toolkit")
>>> pag.getWindows()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pyautogui' has no attribute 'getWindows'
>>> gw.getAllWindows()
[Win32Window(hWnd=65926), Win32Window(hWnd=197754), Win32Window(hWnd=66976), Win32Window(hWnd=330322), Win32Window(hWnd=2886166), Win32Window(hWnd=2231174), Win32Window(hWnd=198554), Win32Window(hWnd=1182658), Win32Window(hWnd=132644), Win32Window(hWnd=6162518), Win32Window(hWnd=67150), Win32Window(hWnd=394798), Win32Window(hWnd=197372), Win32Window(hWnd=66102), Win32Window(hWnd=66096), Win32Window(hWnd=66138), Win32Window(hWnd=264106), Win32Window(hWnd=1182078), Win32Window(hWnd=263054), Win32Window(hWnd=131546)]
>>> gw.getAllTitles()
['', 'Administrator: Command Prompt - python', 'Roadmap — PyAutoGUI documentation - Google Chrome', 'Microsoft Assessment and Planning Toolkit', 'Microsoft Assessment and Planning Toolkit', 'Automate the Boring Stuff with Pytho (13)', 'Inbox - [email protected] - Outlook', 'Microsoft Edge', 'Microsoft Edge', 'Microsoft Edge', 'Microsoft Store', 'Microsoft Store', '', '', '', 'Sticky Notes', '', 'Python GUI Automation Code - Notepad', '1 Reminder(s)', 'Program Manager']
>>> gw.getWindowsWithTitle('Microsoft Assessment and Planning Toolkit')
[Win32Window(hWnd=330322), Win32Window(hWnd=2886166)]
>>> gw.getFocusedWindow()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pygetwindow' has no attribute 'getFocusedWindow'
>>>
>>> gw.getWindowsWithTitle('Microsoft Assessment and Planning Toolkit')
[Win32Window(hWnd=330322), Win32Window(hWnd=2886166)]
>>>
How do I focus/activate only on one of the two windows ([Win32Window(hWnd=330322), Win32Window(hWnd=2886166)])?
OR
If there is only one window like say notepad among 10 other applications open.How do I focus on only notepad and start working on that application ?
Thanks
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020