2 ms·
By the way, for those wondering about convenience, this will wait 3 seconds (during which you switch to your web browser and click the password field) and then
by dheera 9y ago
By the way, for those wondering about convenience, this will wait 3 seconds (during which you switch to your web browser and click the password field) and then it will "type" the password. (You do NOT want to cut-and-paste your password from a terminal as the clipboard can be read by anything.)
# requires: sudo apt-get install xautomation for 'xte'
import time
from subprocess import Popen, PIPE
macro = ""
for char in password:
if char == '$':
macro += "keydown Shift_L\nkey 4\nkeyup Shift_L\n"
elif char == '+':
macro += "keydown Shift_L\nkey equal\nkeyup Shift_L\n"
elif char == '/':
macro += "key slash\n"
elif char.isupper():
macro += "keydown Shift_L\nkey %s\nkeyup Shift_L\n" % char
elif char.islower() or char.isdigit():
macro += "key %s\n" % char
print("Entering password in 3 seconds ... [^C to abort]")
time.sleep(3)
Popen(['xte'], stdin=PIPE).communicate(macro.encode())
- shocks 9y agoI cleaned it up a bit and added the missing keys: https://github.com/wridgers/pwtools/blob/master/bin/pwtype https://github.com/wridgers/pwtools/blob/master/bin/pwtype