How to find a program with the current focus?

How do you know which process has the current focus?

Edit: Windows OS, anywhere from XP to 7

+8
c ++ windows focus
source share
3 answers

Call GetForegroundWindow to get the handle of the focused window, and then call GetWindowThreadProcessId to get the ID of the process that created this window. What you do with this ID is up to you.

+9
source share

You can use EnumProcesses to get a list of running processes.

After you retrieve the descriptors, check out GetProcessInformation , maybe something may help you.

+2
source share

the first steps are the winapi EnumProcesses function (and possibly OpenProcess)

+1
source share

All Articles