Reputation: 612
I was trying to implement key-logger and mouse-logger in .net. So I have a class KeyLog
and MouseLog
. Inside both class's constructor, I have this same logic :
MouseLog:
public MouseLog()
{
_hookID = SetHook(_proc);
Application.Run();
UnhookWindowsHookEx(_hookID);
}
KeyLog :
public KeyLog()
{
_hookID = SetHook(_proc);
Application.Run();
UnhookWindowsHookEx(_hookID);
}
I'm using Application.Run
to keep running the application.
N.B.: It is a console application.
Now I have another class, PLog
(Parent Log), inside that I have :
public PLog()
{
KeyLog();
MouseLog();
}
This PLog
is called from a Main
method. The problem is If I put KeyLog
before MouseLog
in PLog
, MouseLog
doesn't work, else KeyLog
doesn't work.
I can understand the problem, that it is not getting to the next statement, because Application.Run
has already been called. How can I resolve this?
I don't want to use thread as this will keep running as long as the PC runs.
using System.Windows.Forms;
Upvotes: 1
Views: 95
Reputation: 504
Upvotes: 1