Do I need to use Keyboard Hooks to solve my problem?

This is a discussion on Do I need to use Keyboard Hooks to solve my problem? within the C++ Programming forums, part of the General Programming Boards category; Hi there. I am currently working on a project to identify users using their typing dynamics. I want to use ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    5

    Do I need to use Keyboard Hooks to solve my problem?

    Hi there.

    I am currently working on a project to identify users using their typing dynamics. I want to use the intervals
    between keystrokes on the keyboard as a user type in their passwords, to identify the users.

    I am using Windows XP and Visual Studio C++ 2003 to develope a MFC application project. I want to use a dialog with an edit box
    to allow the user to enter his/her username and password.

    I cannot process the WM_KEYDOWN and WM_KEYUP messages because when you type in the edit box, the keyboard focus is
    on the edit box and not on the dialog, and I cannot specify event handler for the messages sent to the edit box.

    Will a keyboard hook help me in my mission or will I have to use something else.


    If you could help me I would appreciate it alot.


    Thank You.
    Ben

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,625
    No, you don't need to use windows hooks. When the dialog box is shown, it will normally have focus if it is modal. IIRC, you can send a WM_SETFOCUS message to whichever control you wish to have keyboard focus.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    5
    Hi grumpsy.

    I havent previously used the *FOCUS* messages to set the focus to specific dialogs. I have worked through Sams teach yourself book for VS C++ and he said that when there is any controls placed on a dialog, the messages will not go to the dialog anymore, but to the control, since the control then have keyboard focus.

    You say I can use the WM_SETFOCUS message to set the focus to the dialog on which I placed the edit box (the edit box is where the user will enter the password). Wouldn't the focus be set back to the edit box when the user starts typing in it?

    Where would be a good place to call the WM_SETFOCUS message for the dialog, to prevent any controls on the dialog to get the keyboard focus?

    Thanx for the rep.
    Ben.

  4. #4
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    try subclassing the edit box, see SetWindowLong index GWL_WNDPROC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 09-14-2008, 07:17 PM
  2. problem solve
    By coolnarugodas in forum C Programming
    Replies: 7
    Last Post: 04-26-2005, 01:31 PM
  3. Replies: 2
    Last Post: 04-25-2005, 12:59 PM
  4. Can someone solve this problem for me?
    By hykyit in forum C Programming
    Replies: 2
    Last Post: 03-17-2005, 02:57 AM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 02:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21