If the foreground app is using standard Win32 UI controls, then try this:
- use
GetForegroundWindow()
to get theHWND
of the foreground window. - then use
GetWindowThreadProcessId()
andGetGUIThreadInfo()
to get the foreground window’s currently focused child control. - then use
GetClassName()
to check if it is a standardEDIT
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 theES_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