Python keylogger written for learning purposes. Utilizes the ctypes
, pyhook
, and win32com
libraries. GetForeGroundWindow
is used to get the current active window on the desktop. That is then passed to GetWindowThreadProcessId
to retrieve the window’s PID. The process and the resulting process handle is used to find the executable name of the process. Then the full text of the window’s title bar using GetWindowTextA
is retreived. PyHook is used to bind the KeyDown
event to the callback function KeyStroke
. PyHook is to hook all keypresses and continue execution. Whenever a key on the keyboard, the KeyStroke
function is called.
This creates and logs to a file called log.txt
in the directory of execution. A windowless compiled standalone executable is also included.