Andrei
Andrei

Reputation: 529

How can I tell if another process has the active foreground window? (Win32 API vb.net)

The user32.dll provides functions to get the process id from a process executable name, and I can also obtain the active or foreground window that the user is working.

Can I determine what windows the targeted process has opened? Otherwise, can I find out what details about the process that opened the foreground/active window?

My code needs to run only when another specific process is running and the user is actively using that window, while that window is the active, foreground, and currently focused window on the desktop.

Upvotes: 2

Views: 1157

Answers (1)

John Knoeller
John Knoeller

Reputation: 34218

I think you want to use GetWindowThreadProcessId or possibly EnumThreadWindows

Upvotes: 2

Related Questions