I was wondering if there was any way through C# or C++ to send to fake or otherwise trick a program into thinking it has focus? I’m thinking that there’s a message you can send to it using SendMessage/PostMessage that’ll trick it into having focus.
Share
There is no guaranteed way to trick it into thinking it has focus because there are multiple ways it can check if it has focus. For example, it could be checking for
WM_SETFOCUSand then checking it is out of focus when it receivesWM_KILLFOCUS. So you could trick it in this case by sending intercepting allWM_KILLFOCUSmessages with a window hook.However, it might also be checking for if it has focus by calling
GetFocus. So to trick it in that scenario, you would need to detourGetFocusand fake the return value. You can try both of these methods and they might work and they might not, but I wouldn’t expect them to work reliably.