-7
import subprocess

path = '/home/test/net.keystore'

text = subprocess.Popen(['keytool', '-list', '-v', '-keystore', path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
file = text.stdout.read().decode().splitlines()
print file

through subprocess i trying to fetch keystore certificate details I don't know password for keystore. If i press "enter key" twice then output is processing

Is there any way to automate "Enter key" in python?

Chris Wesseling
  • 6,226
  • 2
  • 36
  • 72
VJG
  • 21
  • 1
  • 1
  • 6

3 Answers3

8

You can use keyboard module which you can install using pip with command python -m pip install keyboard.

Following code will press the enter key:

from keyboard import press
press('enter')
Jakub Bláha
  • 1,491
  • 5
  • 22
  • 43
1

This installation process worked for me: C:\Python3>pip.exe install keyboard

import keyboard

keyboard.press_and_release('enter')

I used Win10, a simple press('enter') that just deactivated the active button, but press and release worked.

ScottC
  • 3,941
  • 1
  • 6
  • 20
csigeer
  • 11
  • 3
0

You can use:

from selenium.webdriver import ActionChains

ActionChains(self.driver).send_keys(Keys.ENTER).perform()
Balabam
  • 11
  • 4