且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何破解键盘以检查按下了哪个键

更新时间:2023-12-03 09:06:52

您需要注册键盘全局挂钩很简单

SetWindowsHookEx( int idHook,KeyboardHookProc callback, IntPtr hInstance, uint threadId);



并以隐藏模式运行此表单。在回调全局钩子事件时复制键你需要并使用

 CallNextHookEx( IntPtr  idHook, int  nCode, int  wParam, ref 键盘HookStruct lParam)


好的,为什么你知道他们可以解决完全不同的问题?是的,你尝试过的所有方法都与你想要达到的目标无关。这个解决方案很有名,很多次在这个论坛上进行过讨论。



但我真的很想知道,你想要获得什么信息了解用户。这对我来说听起来像是恶意活动。这种担忧比人们想象的更严重。我知道禁止这种开发的公司即使是出于合法目的也是一项特殊法令。



-SA


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

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

[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

It is simple you have to register for keyboard global hook
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

CallNextHookEx(IntPtr idHook, int nCode, int wParam, ref KeyboardHookStruct lParam)


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