1

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

This allows me to send things like mouse clicks to the application:

win.Click(coords=(300,330))

This works fine, and I can also send "TypeKeys" events to the application:

while True:
    win.TypeKeys("w")

However, instead of holding the key down, it repeatedly sends single letters to the game. I need a way to hold the key down instead (and this must be in context of an application, not just a raw keyboard input).

EDIT: I mean I want to send held key presses to applications other than the active window

Max Heslop
  • 51
  • 1
  • 1
  • 9
  • Currently this is not fully implemented in the `keyboard` module interface. But it's easy to add, because `class KeyAction` already contains necessary params `down = True, up = True` in the constructor. Would you like to implement it? Or ready to wait few weeks? We're focusing on "record-replay" for UIA backend and Linux support. So can handle this request a bit later since this is a hobby project. – Vasily Ryabov Jun 02 '18 at 20:40
  • Filed [issue #503](https://github.com/pywinauto/pywinauto/issues/503). – Vasily Ryabov Jun 02 '18 at 20:46
  • Sorry, I would have no idea how to do that! – Max Heslop Jun 03 '18 at 08:10
  • OK, hope we can add this to coming 0.6.5 release. – Vasily Ryabov Jun 03 '18 at 09:28

1 Answers1

0
from pywinauto.keyboard import SendKeys

<...code>
SendKeys('{DOWN}') # Keyboard input
# in case of element
element.type_keys('{DOWN}')

checkout this Link, Hope this will help you.

Sunil Kumar
  • 186
  • 3
  • 12
  • When I say "key down" I mean holding keys down, not down arrow. Also, does this send it the application or just replicate keyboard events in the active window? – Max Heslop Jun 02 '18 at 15:11
  • So after reading the documentation at the link provided, this is not the answer I was looking for. – Max Heslop Jun 02 '18 at 16:30