0

I would like to figure out which UI element (of any other program currently running) currently has the user's keyboard focus - as an example, let's say I'd like to write a small tool that puts a green border around the currently active text field.

Another post makes me think I could achieve this partially by setting up a hook via SetWindowsHookEx to determine where the user clicked, but that would already fail for figuring out where TAB moved the focus to. I was also thinking about using 's inspection features to determine which UI elements are text input fields at all, and maybe there is an inverse GetFocus to its SetFocus. But all this seems rather hackish and unnecessarily complicated, so I thought I'd stop and ask here first:

How to find the UI element that currently has the keyboard focus?

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221

0 Answers0