Force App to Keep Focus.

I’m using a textfield that is automatically positioned off the screen and a timer that fires every second keeping the focus set on a textfield to process a upc scan. My issue is if the user clicks off the main window on the desktop or somewhere else the scan doesn’t get processed. I’m concerned about an automatic update or something similar removing the focus from my app even if I have it maximized. I know about kiosk mode and I’ve used it before but is there another way to use a timer to force the focus back on my app even if it’s lost somehow? Thanks for any advice.

If it’s Mac only you can use a timer and a declare to make your app the active app.

This is bad behavior though; that’s why Kiosk mode exists - specifically for instances where they shouldn’t be allowed access to anything else. Otherwise, in normal usage, if the user wants to click off your app to do something else they should be allowed to.

@Tim Parnell That sounds about right. I just thought maybe I was overlooking another way outside of the ways you just described. I just hate to lock the entire OS down in kiosk mode over this one thing. Thanks for the reply. :slight_smile:

Maybe (actual) full screen mode?

Yeah that works but a automatic update finishing would bring a reboot dialog to the front of my app and cause it to lose focus. The OS will be completely unattended so if my app loses focus there would be no way to restore focus without a manual power off and on. I’m also going to be running a web app as a system service to handle updating the settings, essentially updating a SQLite db file. I wonder if having the OS in kiosk mode would affect the ability to access my web app running as a system service?

Axel Schneider posted a Mac declare for an app to get in front of all other apps. If you place it in the window deactivate, it will become impossible to escape it.

You can do the same thing for Windows with RemoteControlMBS.

But I do concur with Tim. This rude to the user. The desktop metaphor is precisely built so the user is supposed to click and access whatever resource is on the screen. He may even think the computer is stuck and reboot.

Kiosk is the only well behaved way to keep focus.

If the issue is that your app no longer gets the scan when the app is not in front, maybe you want to use a service that keeps listening and storing scans, and the app simply fetches the scans. That would allow the app to go out of focus and the user do whatever he pleases.

Thanks for all the input I appreciate it. I’ll probably just use kiosk mode as long as it won’t interfere with my web interface running as a system service.