0

I am currently attempting to build a program that automates a simple addition calculation using pyautogui by copying and pasting a number. So far, my code looks like this (without the hypothetical coordinates of what the program is supposed to copy):

pyautogui.keyDown("ctrl")
pyautogui.press("c")
pyautogui.keyUp("ctrl")
n = input("Insert a number: "
pyautogui.keyDown("ctrl")
pyautogui.press("v")
pyautogui.keyUp("ctrl")
print(n + n)

The problem with this code is that the input statement halts the program, which means that the program can't insert the copied element in the input statement. Is there a workaround or a different solution to storing the copied element inside a variable using pyautogui?

  • 1
    You're missing the closing ) after your input. n = input("Insert a number: ") – BWallDev Aug 11 '21 at 17:31
  • [`input()`](https://docs.python.org/3.8/library/functions.html#input) reads from console and _waits_ for ENTER pressed. This _wait_ is blocking. Then the input is read into variable `n` which is not the clipboard from where it can be pasted using CTRL + V. – hc_dev Aug 11 '21 at 17:32

0 Answers0