Python send keystrokes to exe file

Yomal

I need to send keystrokes to an exe using python. I can run the exe using python from subprocess as

import subprocess
subprocess.Popen('myfile.exe',stdout=subprocess.PIPE)

but how can I keep the connection and keep sending keys. I don't want to read back from the exe just to send some keystrokes any suggestions

user707650

Use stdin=subprocess.PIPE and Popen.communicate():

Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be data to be sent to the child process, or None, if no data should be sent to the child. If streams were opened in text mode, input must be a string. Otherwise, it must be bytes.

communicate() returns a tuple (stdout_data, stderr_data). The data will be strings if streams were opened in text mode; otherwise, bytes.

Note that if you want to send data to the process’s stdin, you need to create the Popen object with stdin=PIPE. Similarly, to get anything other than None in the result tuple, you need to give stdout=PIPE and/or stderr=PIPE too.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SEND clip as keystrokes

From Dev

Using cat() to send keystrokes to console

From Dev

EXE file for python scripts

From Dev

EXE file for python scripts

From Java

Keystrokes not registering in Python/Pygame?

From Dev

Python to EXE file in one file

From Dev

How To Send Multiple Keystrokes From Code Behind

From Dev

Send keystrokes to a specific window using PowerShell

From Dev

send keystrokes from unicode string pyqt pyside

From Dev

How to send separate keystrokes to separate programs?

From Dev

send keystrokes from unicode string pyqt pyside

From Dev

How to Run an .exe File in Python

From Java

How to open an exe file in python and continue without close exe file?

From Dev

How can I send a file, for example "exe", with Telnet?

From Dev

How to send exe file in telegram bot from url

From Dev

python requests send string as file

From Dev

Send Python information to a JavaScript file

From Dev

send and receive a file in python sockets

From Dev

How to run exe file from python script converted to exe

From Dev

Make exe file from python selenium tests

From Dev

python exe unable to generate csv file

From Dev

Python to EXE builds a nothing-doing file

From Dev

Run .exe file via Python as Administrator

From Dev

Run compiled python .exe with a file as input

From Dev

How to run/execute exe file in python?

From Dev

Python to EXE builds a nothing-doing file

From Dev

Open an .exe file and give it input parameters in Python

From Dev

Sending keystrokes to an application, SendKeys.Send() vs SendMessage()

From Java

Send keystrokes to non-active GUI application without occupying the keyboard

Related Related

HotTag

Archive