[Solved] Differentiating between password and other kind of keyboard inputs in a keylogger


If the foreground app is using standard Win32 UI controls, then try this:

  • use GetForegroundWindow() to get the HWND of the foreground window.
  • then use GetWindowThreadProcessId() and GetGUIThreadInfo() to get the foreground window’s currently focused child control.
  • then use GetClassName() to check if it is a standard EDIT control (this check might fail in some UI frameworks! You might have to use the UI Automation API to detect the control type)
  • then use GetWindowLong/Ptr() to check if it has the ES_PASSWORD style applied.

However, if the foreground app is not using standard Win32 UI controls, and/or is custom-drawing them, or the like, then all bets are off.

solved Differentiating between password and other kind of keyboard inputs in a keylogger