Just use

# from pywinauto.SendKeysCtypes import SendKeys # old for pywinauto==0.5.x
from pywinauto.keyboard import send_keys

send_keys('some text{ENTER 2}some more textt{BACKSPACE}', with_spaces=True)

Docs: https://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html

P.S. SendKeysCtypes was renamed to keyboard in pywinauto 0.6.0+.

Answer from Vasily Ryabov on Stack Overflow
🌐
Readthedocs
pywinauto.readthedocs.io › en › latest › code › pywinauto.keyboard.html
pywinauto.keyboard — pywinauto 0.6.8 documentation
Automate typing keys or individual key actions (viz. press and hold, release) to an active window by calling send_keys method.
Discussions

Send keystrokes not work for notepad and other programs
Windows GUI Automation with Python (based on text properties) - pywinauto/pywinauto More on github.com
🌐 github.com
3
April 7, 2022
how do I use SendKeys? I am using pywinauto 0.6.5 and Python 3.5.1
I am trying to send the following ####to a terminal window### from pywinauto import keyboard keyboard.SendKeys.send('jsmith') ######################## but when I try to run the above, I rec... More on github.com
🌐 github.com
1
August 7, 2018
winforms - How to send SendKeys to Windows form in python script? - Stack Overflow
In that I'm sending TAB key/any key to my windows form. But I'm not able to find handle of that Windows form in my Python script. ... __author__ = 'juhis' import SendKeys import sys import os from Tkinter import * import ctypes import win32gui import pywinauto pwapp = pywinauto.application... More on stackoverflow.com
🌐 stackoverflow.com
July 11, 2018
python - pywinauto send key down to application - Stack Overflow
I want to send key down events to game applications using pywinauto. I get the application like this: from pywinauto.application import Application app = Application() app.connect(title='Adobe Flash Player 29') win = app.window_(title_re = "Adobe Flash Player 29") More on stackoverflow.com
🌐 stackoverflow.com
🌐
Readthedocs
airelil-pywinauto.readthedocs.io › en › latest › code › pywinauto.keyboard.html
pywinauto.keyboard — pywinauto 0.6.6 documentation
Automate typing keys or individual key actions (viz. press and hold, release) to an active window by calling send_keys method.
🌐
GitHub
github.com › pywinauto › pywinauto › issues › 1202
Send keystrokes not work for notepad and other programs
April 7, 2022 - send_keystrokes · from pywinauto.application import Application app = Application().connect(title_re="a.txt") app.top_window().send_keystrokes("aaaaa") Pywinauto version: 0.6.8 · Python version and bitness: 3.7 · Platform and OS: windows 10 · No one assigned ·
Author   gitE0Z9
🌐
GitHub
github.com › pywinauto › pywinauto › issues › 533
how do I use SendKeys? I am using pywinauto 0.6.5 and Python 3.5.1 · Issue #533 · pywinauto/pywinauto
August 7, 2018 - I am trying to send the following ####to a terminal window### from pywinauto import keyboard keyboard.SendKeys.send('jsmith') ######################## but when I try to run the above, I rec...
Author   volksmania
🌐
Stack Overflow
stackoverflow.com › questions › 50656751 › pywinauto-send-key-down-to-application
python - pywinauto send key down to application - Stack Overflow
I want to send key down events to game applications using pywinauto. I get the application like this: from pywinauto.application import Application app = Application() app.connect(title='Adobe Flash Player 29') win = app.window_(title_re = "Adobe Flash Player 29")
🌐
Readthedocs
pywinauto-fork.readthedocs.io › en › latest › code › pywinauto.keyboard.html
pywinauto.keyboard — pywinauto 0.6.5 documentation
Automate typing keys or individual key actions (viz. press and hold, release) to an active window by calling send_keys method.
Find elsewhere
🌐
Python Forum
python-forum.io › thread-17735.html
[PyWinAuto] Please help me with Typekeys ()
Hello everyone, I have some code as below: from pywinauto import application from pywinauto import keyboard app = application.Application() app.connect(path= r'C:\Windows\system32\cmd.exe') dlg = app.top_window_() dlg.TypeKeys('cd /d C:\Program Files...
🌐
Reddit
reddit.com › r/learnpython › pywinauto not sending keystrokes to application
r/learnpython on Reddit: pywinauto not sending keystrokes to application
May 19, 2024 -

Hello,

I'm new to using pywinauto for some automation. I'm in the process of making a program that can automate on Pokemon Heartgold by using DesMuME. Initially, I was using pyautogui to automate the keystrokes and it was working perfectly. However, pyautogui needs the window to be in focus, which makes it so that I cannot use my computer to do other things in the meantime. This is when I started looking into pywinauto, to try and send keys to the program in the background while I do other things.

The issue is that none of the keystrokes are being sent. I'm still very new to pywinauto, and I might be doing things incorrectly, but I am not entirely sure. I've tried methods like type_keys(), send_chars() and send_keystrokes() but I was getting errors on each of them. I tried importing the send_keys() method from pywinauto.keyboard, but it doesn't work.

This is the code I have so far to initialize the application:

from pywinauto import Application
from pywinauto.keyboard import send_keys
import pywinauto
import time

app = Application(backend='uia').connect(title_re='DeSmuME')
desmume = app.window(title_re='DeSmuME')

# Even trying to send keystrokes while the window is focused, no luck
# desmume.set_focus()

# attempts at sending keys:
desmume.type_keys('{UP}')
desmume.send_chars('{UP}') # Error 
desmume.send_keystrokes('{UP}') # Error
send_keys('{UP}')

I don't really know what else there is to try. The pyautogui solution works as it should, but this would make it so much easier to run the program and leave it in the background while I do other things. If anyone knows how to fix, I would greatly appreciate it.

🌐
Reddit
reddit.com › r/learnpython › how do i send keystrokes to a background window using python?
r/learnpython on Reddit: How do I send keystrokes to a background window using Python?
July 26, 2020 -

Tried this code:

import win32gui
import win32con

windowID = win32gui.FindWindow(None, "testing.pdf - Adobe Acrobat Pro DC")
#win32gui.SetForegroundWindow(windowID)
win32gui.SendMessage(windowID, win32con.WM_KEYDOWN, win32con.VK_NEXT, 0) #VK_NEXT is Page Down button

Above code works only if i de-comment the SetForegroundWindow line. Why won't it work without it? :(

I wish to keep the terminal in focus while my script does tasks on a window in the background. (mainly sending differenbt keystrokes like ctrl+Tab, pgDn/pgUp, etc)

🌐
GitHub
github.com › pywinauto › pywinauto › issues › 133
SendKeys/TypeKeys always sends text to active window, ignores target · Issue #133 · pywinauto/pywinauto
January 19, 2016 - Using Windows 7, Anaconda Python 3.5 (32bit). pxplus[u'Edit4'].TypeKeys('9.26') Simply sends the text 9.26 directly to my text editor instead of the control specified. I've tried this with other controls also without success. Unfortunate...
Author   ghost
🌐
Read the Docs
app.readthedocs.org › projects › airelil-pywinauto › downloads › pdf › latest pdf
pywinauto Documentation Release 0.6.6 The pywinauto contributors community
July 28, 2006 - pywinauto is a set of python modules to automate the Microsoft Windows GUI. At it’s simplest it allows you to send · mouse and keyboard actions to windows dialogs and controls.
🌐
YouTube
youtube.com › rafique javed
Desktop GUI Automation using Keyboard Controls || Python PywinAuto || Simplest way to Automate - YouTube
This video describes about automating a GUI application using Keyboard Controls.Link for Keycodes,https://pywinauto.readthedocs.io/en/latest/code/pywinauto.k...
Published   August 6, 2020
Views   4K
🌐
Reddit
reddit.com › r/python › another example for pywinauto
r/Python on Reddit: Another example for pywinauto
September 12, 2018 - Put result from Calculator to Notepad. This is so far from perfect but I hope every one can help make this code better for any Python newbie. Here the code on my github. Happy coding. ... # Another pywinauto example from pywinauto import Desktop, Application, keyboard import time # Open Calculator in Windows 10 and do some calculation app = Application(backend='uia').start("calc.exe") dlg = Desktop(backend="uia").Calculator dlg.type_keys('3') # Add some delay between each key stroke time.sleep(1) dlg.type_keys('/') time.sleep(1) dlg.type_keys('7') time.sleep(1) dlg.type_keys('=') # Get calcula
🌐
GitHub
github.com › pywinauto › pywinauto › issues › 1111
Sendkeystrokes and Mouseclick on minimized window · Issue #1111 · pywinauto/pywinauto
September 11, 2021 - from pywinauto.application import Application target_window = win32gui.FindWindow(None, (args["windowtitle"])) app = Application() app.connect (handle=target_window) app.window(title=args["windowtitle"]).send_keystrokes("{VK_ESCAPE}") app.window(title=args["windowtitle"]).click(button='left', coords=(1191,1044))
Author   madtatu-development
🌐
Radiosky
radiosky.com › rjp3 › rjp3help › sendkeys_reference.html
SendKeys Reference
Note You can't use SendKeys to send keystrokes to an application that is not designed to run in Microsoft Windows.
🌐
Rpaframework
rpaframework.org › libraries › desktop_windows › python.html
Python API — RPA Framework documentation
The keyword type_keys sends keys to the active window element. Special key codes are documented on pywinauto documentation page.