Python Forum
set_focus() in python pywinauto
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set_focus() in python pywinauto
#1
I am trying to create a script that will cycle through 4 open windows. I am able to connect to the open windows fine. But I cannot figure out how to set_focus() on a window. I have read the documentation and googled, but cannot figure out what I am missing. I appreciate the advice.

My existing code is:
import pywinauto
 
apps = []
windows = pywinauto.Desktop(backend="uia").windows()

for w in windows:
    if 'Microsoft' in w.window_text():
        apps.append(pywinauto.Application().connect(handle=w.handle))

for x in apps:
    x.set_focus()
#I also tried:
    pywinauto.set_focus(x)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  MemoryError in pywinauto.findwindows.find_windows – Need Help! ktw3857 0 119 Mar-25-2024, 02:23 AM
Last Post: ktw3857
  Pywinauto typing in the wrong field EGameiro 0 656 Jun-07-2023, 10:01 PM
Last Post: EGameiro
  Help ~ coding with pywinauto NickNHartley 1 2,193 Apr-20-2023, 05:20 PM
Last Post: farshid
  pywinauto, anyone use it? thewolf 1 2,787 Mar-01-2021, 09:58 PM
Last Post: snippsat
  Kindly asking for help with Pywinauto louloulou 0 1,991 Mar-05-2020, 06:55 PM
Last Post: louloulou
  Checking the presence of label using pywinauto module Malt 0 1,885 Jul-26-2019, 09:06 AM
Last Post: Malt
  [PyWinAuto] Please help me with Typekeys () mattroi261192 2 7,804 Apr-23-2019, 01:55 AM
Last Post: mattroi261192
  Not able to convert PYWINAUTO module automation in exe file Utkarsh29 0 2,398 Mar-19-2019, 09:39 PM
Last Post: Utkarsh29
  pywinauto problems vnc 3 8,081 Apr-13-2017, 11:21 AM
Last Post: vnc
  pywinauto timings timout error stonetr33 4 11,347 Dec-07-2016, 12:55 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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