Is it possible to force OF app window to maintain focus?

I am making an OF app for Windows 10 and I have a problem with another app, working with the OF app, opening a window every so often and stealing focus from the fullscreen OF app.

Is there any way to prevent this either by disabling focus stealing or forcing the OF app to maintain focus?

Call SetWindowPos with HWND_TOP

1 Like

Thanks for the response. Tried your suggestion as specified here by Zach, but it doesn’t seem to do the trick. It might only bring the window to the front, but not focus it.

It is a brute force method, but what about writing the following in update?

void ofApp::update()
    HWND AppWindow = GetActiveWindow();

How about this?

1 Like


A dirty fix I made some years ago was to use AHK.


WinWaitActive, ahk_exe annoying_app.exe
WinActivate, ahk_exe of_app.exe
goto, loop

Once started, the script wait for a window for annoying_app.exe to receive the focus, then give the focus back to the of_app.exe window.

This technically works, but what it does is grabs focus for the app in every frame. So when the focus is taken by the other app, there is an abrupt but noticeable flash of black screen, before the app regains focus. So this doesn’t solve my problem, unfortunately.