>>> 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