Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
Hello every one
I m developing an application which is used to hack the key board ..
In my windows application i need to have a details of key pressed in on computer key board .I need to store all the key pressed details in a word or .txt file . I will think late to store now i want to get the value which key has been pressed. I saw in internet It can be done through form key pressed event
C#
private void Mainform_KeyPress(object sender, KeyPressEventArgs e)
        {

        }



But for this the form should appear . I want to know the key pressed details without knowing to user. Even i used the Key pressed event using this code

C#
[DllImport("user32.Dll")]
       public static extern int keybd_event(byte ch, byte scan, int flag, int info);



but this method is used to input the key data to computer . But i need to get the value
So can any one tell me how to do this Is there any link,example or any other DLL .

Advance Thanks
Arun
Posted
Comments
Xeshan Ahmed 12-Oct-11 2:05am    
it is quite simple ....... and nobody should have concern what you are going to make any key-logger, spyware etc because its all technology.
Xeshan Ahmed 12-Oct-11 2:05am    
use Keyboard Global Hooks

It is simple you have to register for keyboard global hook
C#
SetWindowsHookEx(int idHook, KeyboardHookProc callback, IntPtr hInstance, uint threadId);

in your form and run this form in hidden mode.In callback of you global hook event copy the key you required and forward it to next hook using
C#
CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref KeyboardHookStruct lParam)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Oct-11 15:07pm    
My 4. You also should have mentioned that a separate DLL is required if the hook is global (according to Microsoft documentation).
Cheers,
--SA
Xeshan Ahmed 14-Oct-11 2:41am    
thanks for sharing but i am using global hooks since so long but have not faced such type of problem to introduce separate dll, so try it by yourself as well, hope you will find some good results.
OK, and why did you put these wrong ways in your question knowing they can solve completely different problems? Yes, all ways you tried have nothing to do with what you wanted to achieve. And the solution is well-known, was discussed in this forum many times.

But I would really would like to know, what information would you like to obtain "without knowing to user". It sound too much like malicious activity to me. This concern is more serious than one may think. I know companies where such development is prohibited be a special decree even for legitimate purpose.

—SA
 
Share this answer
 
Comments
arunrv 12-Oct-11 4:27am    
how can say its a malicious activity . There are so many ready software all ready developed and can get in market. But i want to do it myself . I want result like . when user press a key 'A' i will create a static path where a txt file is created and letter 'A' will be written in that,similarly when user type 'G' a 'G' letter should be written in that ......
Sergey Alexandrovich Kryukov 13-Oct-11 15:04pm    
I cannot say so. I say it looks like. I don't see why doing so. Why? OK, correct answer is using Windows hook. And what's wrong is this: "without knowing to user". Are you opposing to your user?
--SA
Xeshan Ahmed 12-Oct-11 8:08am    
good good

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900