Set focus on console in Windows?

2019-06-26 09:02发布

问题:

Is it possible to set focus on a console app in Windows? SetFocus looks promising, but it needs an HWND and I don't know if console apps even have one.

回答1:

Use the GetConsoleWindow function.