My code is:

import win32api, win32con shell = win32com.client.Dispatch("WScript.Shell") shell.SendKeys("{DELETE}") shell.SendKeys("{DEL}") 

nothing happens when it works

what am I doing wrong?

  • shell.sendKeys(Keys.DELETE); But it cannot work to remove the input text, you must use shell.sendKeys(keys.BACKSPACE); - Let's say Pie

1 answer 1

There is such a module pyautogui .

The example below will enter '12390' , then delete the last two digits and add '45' :

 # pip install pyautogui import pyautogui pyautogui.typewrite('12390') import time time.sleep(0.5) pyautogui.press('backspace') # Вариант клика 1 pyautogui.typewrite(['backspace']) # Вариант клика 2 pyautogui.typewrite('45')