TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
veeresh veeresh
NA
3
0
Application KeyBoard Hook in C#.Net
May 12 2010 8:39 AM
Hi All,
I am working on Application Keyboard hook in C#.Net.
I need to do some funcationlity when user presses "Esc" key in my application.
Iam able to capture "Esc" key in the application, but hookprocedure is calling two times when ever i press "Esc" button and in turns my functionality is calling two times.
Iam sure iam pressing "Esc" key only one time.
Please help me in this.
following is code snippet.
hook procedure
public static int KeyHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
//MouseHookStruct MyMouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct));
if (nCode < 0)
{
}
else
{
if (wParam.ToInt64() == 27)
{
Form1 obj = new Form1();
obj.myfunction();
}
else
{
return CallNextHookEx(hHook, nCode, wParam, lParam);
}
}
return 0;
}
Hook Initialization:
KeyHookProcedure = new HookProc(Form1.KeyHookProc);
hHook = SetWindowsHookEx(WH_KEYBOARD,
KeyHookProcedure,
(IntPtr)0,
AppDomain.GetCurrentThreadId());
Thanks and Regards,
Veeresh.
Reply
Answers (
2
)
scroll event
datagrid column width?