0

This is more of a theoretical question but not sure where to start.

I run my scripts inside of PyCharm but am trying to automate a process.

Before running the PyCharm script I do the following manual tasks:

1 - open an .exe program (from desktop)
2 - once the program opens i need to press the "Y" key to produce a spreadsheet to be used

And then I run the analysis script in PyCharm using the generated spreadsheet.

Is there anyway I can automate the first two steps from within a PyCharm Script?

Thanks very much!

1 Answer 1

1

You can start by installing the PyAutoGui module. pip install pyautogui from your command line. There's a lot of helpful functions here you can use but for your purpose pyautogui.press('y') should work fine. So if you try:

import pyautogui
from time import sleep
import subprocess

subprocess.Popen("directory to app's exe")
# Delay for app to load up
sleep(10)
pyautogui.press("Y")
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! this seems to work - do you know if there is a way to avoid a Y being then placed inside the code window in Pycharm when it runs?
i doubt there is. you have to specify the key you're pressing. Is that what you mean?
yeah it just puts a y in the program/subprocess but also inside my code in pycharm if thats where my cursor currently is. All good no big issue, thanks so much!
You should read Automating the boring stuff by Al Sweigart. It's explained in there, the module and most of it's functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.