How to capture keypresses ????? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to capture keypresses ?????

Does anyone know how to capture keypresses in Windows e.g. keys pressed in a password box ??? Any help appreciated


  • Well, lots of ways!

    - For password edit boxes, FindWindow() the box and then SendMessage(hWndEdit,EM_SETPASSWORDCHAR, 0L, 0L) to remove the passwordability.

    - This not sure 100% about, cant you send a WM_COPY to an edit box? Then get the content from clipboard. Maybe combined with the point above it will work.

    - Can always use a system wide hook and subclass the window you want, or just wait in WH_KEYBOARD and look for the keyboard strokes, GetForegroundWindow() retrieves the window this kbd message will go to. Note, system wide hooks must reside in a DLL, and use no thread ID but the DLL instance instead, other than that they are like normal hooks.


Sign In or Register to comment.