Mar-02-2017, 02:02 AM
Hi all,
I am trying to write a simple "Keylogger" code using python.
I am really on the beginning of the code, yet I found a weird error.
my code:
my code suppose (as much as i know) to write my user name every time i press a character on my keyboard, yet the output is:
I tried searching online yet didn't find anyone that had the same error as me, also tried reading the documentation of getpass, but didn't find anything useful regarding my error.
more information:
I am running this code on : pycharm
python interpreter : 2.7
operating system :windows 10
When i tried to add a few rows to my code:
In this case i wanted to print my computer name each time i switch tabs on my browser, yet the function getpass.getuser() didn't work even a single time:
Thanks in advance,
Nirel.
I am trying to write a simple "Keylogger" code using python.
I am really on the beginning of the code, yet I found a weird error.
my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import getpass import pyHook import pythoncom def a(event): try : print getpass.getuser() except Exception as error: print error hm = pyHook.HookManager() hm.KeyDown = a hm.HookKeyboard() pythoncom.PumpMessages() |
Output:Nirel
an integer is required
an integer is required
an integer is required
As you can see, the first time I pressed a button, the code gave me the correct output of: Nirel (my computer name), yet every key I press since then I got an error of: "an integer is required".I tried searching online yet didn't find anyone that had the same error as me, also tried reading the documentation of getpass, but didn't find anything useful regarding my error.
more information:
I am running this code on : pycharm
python interpreter : 2.7
operating system :windows 10
When i tried to add a few rows to my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import getpass import pythoncom import pyHook def a(event): if a.b = = None : a.b = event.WindowName if event.WindowName ! = a.b: try : print getpass.getuser() a.b = event.WindowName except Exception as error: print error a.b = None a.userinput = "" hm = pyHook.HookManager() hm.KeyDown = a hm.HookKeyboard() pythoncom.PumpMessages() |
Output:an integer is required
an integer is required
an integer is required
If anyone knows why this bug is happening and can help me it would be highly appreciated.Thanks in advance,
Nirel.