I am trying to make a simple keylogger with pyHook or msvcrt.
Both modules work fine when I compile the code and run the .exe file.
But when I'm trying to run the .exe as a windows service (using NSSM if that's matter), the service does not seem to log the pressed keys.
I know the service is working, because it is writing to the files, communicating with sockets etc.
The problem is only with the keylogger.
I suspect the problem is that the service runs in it's own environment so it doesn't recognize the key presses.
Any suggestions how to bypass it?
Here is the keylogger:
while True:
c = msvcrt.getch()
if ord(c) == 8:
buffer = buffer[:-1]
else:
buffer += c
# write the buffer to file
Thanks in advance.