0

I would like to make a timer from the last keystroke to the current time in Python. I have created a program the decrypts a .txt file and then opens it. I would like to have a time out, so after 3 minutes of no typing, it would close the file and encrypt it. I need a method of making python know when there is a keystroke and then it needs to set the current time as a variable which I can later subtract from the current time.

pyAesCrypt.decryptFile(r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\resources\secrets.txt.encrypted", r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\temp\secrets.txt", password, bufferSize)
notFin = True
os.startfile(r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\temp\secrets.txt")
while notFin == True:
    fin = input("Have you finished? ")
    if ('no' in fin) or (fin == 'n'):
        print('Ok')
    else:
        #if it yes or anything else
        notFin = False
        print('Encrypting...')
        # encrypt
        pyAesCrypt.encryptFile(r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\temp\secrets.txt", r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\resources\secrets.txt.encrpyted", password, bufferSize)
        os.remove(r"C:\Users\widdl\Documents\Libraries\Programming\Python\Python_NAI\temp\secrets.txt")
        print('Finished')

I am fairly new to Python as a whole, but I am learning fast. This is my first post on Stackoverflow, although I have read a lot on here before.

Edit: I’m more specifically interested on how to actually register the input from the keyboard. In this case, I want to be able to type in a different window, and for that to start a countdown

edcodes1104
  • 1
  • 1
  • 2
  • See if this helps. Its a similar problem : https://stackoverflow.com/questions/15528939/python-3-timed-input – MoonMist Feb 04 '19 at 22:42
  • Possible duplicate of [Python 3 Timed Input](https://stackoverflow.com/questions/15528939/python-3-timed-input) – Gricey Feb 05 '19 at 00:23

0 Answers0