How to send TAB button using Python in SendKey and PywinAuto modules

This is my code that will open the window and send the keys to the window, but some screens do not work

from pywinauto.application import *
import time
app=Application.Start("Application.exe")
app.window_(title="Application")
time.sleep(1)
app.top_window_().TypeKeys("{TAB 2}")
+5
source share
1 answer
  • Make sure you use the exact window you need. top_window_()may return a completely different window.

To check, run:

app.top_window_().DrawOutline() #Highlight the window

2. The window may be inactive, before typing, set it:

window = app.top_window_()
window.SetFocus()
window.TypeKeys("{TAB 2}")

3. Moreover, you may need to click on the window.

window.Click()
window.TypeKeys("{TAB 2}")
+5
source

All Articles