CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Join Date
    Jun 2006
    Posts
    148

    change the Keybord Input

    How to change the input from keyboard before it has been processed by the target window?

    Thanx for any kind of help...
    Regards,
    Shail2k4

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: change the Keybord Input

    Using WH_KEYBOARD hook, I guess.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by VictorN View Post
    Using WH_KEYBOARD hook, I guess.
    Thanx for the reply...

    Only one thing in my mind is that the input must be changed before the application processes it.

    Consider an application A which contains a text field sey "Name". Now if user types "A" in the "Name" field then it should be changed to "B".

    Regards,
    Shail2k4

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: change the Keybord Input

    Why do you want to do that?

    You won't find help writing malicious code here.

  5. #5
    Join Date
    Jan 2008
    Posts
    48

    Re: change the Keybord Input

    Quote Originally Posted by shail2k4 View Post
    Consider an application A which contains a text field sey "Name". Now if user types "A" in the "Name" field then it should be changed to "B".
    The complete code in C had been posted many times on api ng
    news://nntp.aioe.org/comp.os.ms-wind...ogrammer.win32
    since '90s
    - and it's not with WH_KEYBOARD)

  6. #6
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by GCDEF View Post
    Why do you want to do that?

    You won't find help writing malicious code here.
    I want to break up a barcode input into two string by replacing some special characters. The best way i know is by using hooks.

    Thanx for any kind of help,
    Regards,
    Shail2k4

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: change the Keybord Input

    Quote Originally Posted by shail2k4 View Post
    I want to break up a barcode input into two string by replacing some special characters. The best way i know is by using hooks.

    Thanx for any kind of help,
    Regards,
    Shail2k4
    What does that have to do with your original question?

  8. #8
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by GCDEF View Post
    What does that have to do with your original question?
    Barcode scanner is connected to the keyboard via PS2 port, the scanned code is same as the keyboard input and i can monitor it with the WH_KEYBOARD hook but can not change.

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: change the Keybord Input

    Quote Originally Posted by shail2k4 View Post
    Barcode scanner is connected to the keyboard via PS2 port, the scanned code is same as the keyboard input and i can monitor it with the WH_KEYBOARD hook but can not change.
    Perhaps you could do something with PreTranslateMessage or handling WM_CHAR.

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: change the Keybord Input

    Quote Originally Posted by shail2k4 View Post
    ... i can monitor it with the WH_KEYBOARD hook but can not change.
    Could you show how you have tried to change it?
    Victor Nijegorodov

  11. #11
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by GCDEF View Post
    Perhaps you could do something with PreTranslateMessage or handling WM_CHAR.
    The barcode input may be in any application, means that the barcode data should be changed on the scanning globally.

    The global hook can monitor the code. now how can i use PreTranslateMessage message globally.

  12. #12
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by VictorN View Post
    Could you show how you have tried to change it?
    Code:
    LRESULT CALLBACK KeyboardProc(INT nCode, WPARAM wParam, LPARAM lParam)
    {
    	if (nCode != HC_ACTION)
    		return ::CallNextHookEx(g_hHook, nCode, wParam, lParam);
    if(wParam==' ' || wParam==',')
    	wParam=0x0d;
    return ::CallNextHookEx(g_hHook, nCode, wParam, lParam);	
    }
    Please suggest me if it is wrong.

  13. #13
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Is there any way that i can block the input of "," or "#" or SPACE and replace it with ENTER using the WH_KEYBOARD hook ?

  14. #14
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: change the Keybord Input

    Quote Originally Posted by shail2k4 View Post
    Please suggest me if it is wrong.
    I never used global hooks, therefore can only guess: perhaps, you should also change the scan code part of LPARAM?
    Another variant - try to SendInput with VK_RETURN instead.
    Victor Nijegorodov

  15. #15
    Join Date
    Jun 2006
    Posts
    148

    Re: change the Keybord Input

    Quote Originally Posted by VictorN View Post
    I never used global hooks, therefore can only guess: perhaps, you should also change the scan code part of LPARAM?
    Another variant - try to SendInput with VK_RETURN instead.
    Everything is resolved for the Window Based Application, the need was to use WH_GETMESSAGE.

    Now only one thing is that its not working for DOS based application.

    Regards,
    Shail2k4

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured