Link to home
Start Free TrialLog in
Avatar of sasllc
sasllcFlag for United States of America

asked on

How to always keep focus on a Win7 app?

The customer runs a simple app on his Win7 Pro PC out in the warehouse.  It just sits there waiting for data from barcode scanners and scales.  Everything is fine until it loses focus now and then.  Usually we can't see anything causing this, so my guess is that it is something going on in Windows or in another app, "behind the scenes", but still somehow taking the focus off the app they are trying to run.

I have removed a few things that came with the computer that might normally pop up and ask questions.  Literally nothing is still activated in msconfig.  They ARE running Norton Internet Security, but like I say, I have never seen it--or anything else--up on the screen when this happens, so I don't know what is causing the loss of focus.

It is a big deal for them, because when this happens, their scan and weight data is not going to the app, and if they don't see this happening on the screen, the data is lost.  So I wonder if there is some type of Windows setting that will always insure that the warehouse app keeps focus, no matter what else might be going on in the background.  Or, is there some other way to solve this annoying problem?  TIA
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zalazar
zalazar

Can you maybe check what is the value of ForegroundLockTimeout by opening a Registry Editor via:
Start |Run... |regedit
and lookup the value of:
HKEY_CURRENT_USER\Control Panel\Desktop\ForegroundLockTimeout
Hi zalazar,

> this is more a workaround than solving the problem

Yes, it is. As I stated in my opening sentence, I don't know why it is losing focus, so my approach is, indeed, a work-around.

> You can probably accomplish the same with a visual basic script

"You" (or someone else) can — I can't. :)  I know little about VBScript.

> As it's a customer environment it might not be allowed to install extra software.

Maybe, maybe not. They already have a warehouse app, so obviously some extra software is allowed.

> I would prefer a background program which continuously checks or listens if the top/activated window has changed and only then activate back the application window.

If that's what you prefer, I suggest you write it — and in VBScript, if that's your language of choice.

All I've done here is provide a very simple solution that I'm confident will work, but there certainly may be better solutions. Regards, Joe

P.S. @zalazar, I see that you deleted your comment while I was working on the reply offline in my text editor. How come?
sasllc --
What program is taking away the focus?
Has the "simple app " just lost focus and is still running in the background or is it closed (shut down)?
Hi Joe,
Thank you very much for your comments.

> this is more a workaround than solving the problem
#Yes, it is. As I stated in my opening sentence, I don't know why it is losing focus, so my approach is, indeed, a work-around.
Ok

> You can probably accomplish the same with a visual basic script
#"You" (or someone else) can — I can't. :)  I know little about VBScript.
Thanks for the explanation.
I just wrote a small VBScript but noticed that the AppActivate method is not giving the desired effect.

> As it's a customer environment it might not be allowed to install extra software.
#Maybe, maybe not. They already have a warehouse app, so obviously some extra software is allowed.
Ok

>I would prefer a background program which continuously checks or listens if the top/activated window has changed and only then activate back the application window.
#If that's what you prefer, I suggest you write it — and in VBScript, if that's your language of choice.
I do prefer this although it's probably not possible to do that with VBScript and it would require a real programming language like Visual Basic .NET.

>P.S. @zalazar, I see that you deleted your comment while I was working on the reply offline in my text editor. How come?
#I was not completely satisfied with my comments and was just rephrasing it because of the VBScript comment and looking at some other options.
I'm sorry about that.
Thanks again.
Avatar of sasllc

ASKER

Jcimmaron,
I dont know why or how it is losing focus, but it does continue to run on the screen. If I click the top of the window, then it comes back into focus, running properly, collecting data. Just like any other program in Windows that loses focus. The problem is that I don't know why it loses it, nor how to make it never lose it.
sasllc ----
So  you are saying the "simple app" is not losing focus to another window (and no other app is running behind it), but rather the "simple app" just becomes semi -inactive?
> small VBScript but noticed that the AppActivate method is not giving the desired effect

Hmmm, very interesting! Knowing little about VBScript, I can't help with that. I can say that AutoHotkey's WinActivate command has always worked well for me, and numerous EE members have been happy with it when I recommended it. Here are just three recent examples (there are more in the past) where it worked for folks:

https://www.experts-exchange.com/questions/28486055/Script-to-swap-active-programs-in-Windows-7.html
https://www.experts-exchange.com/questions/28517572/WIndows-7-is-it-possible-to-switch-between-program-automatically.html
https://www.experts-exchange.com/questions/28519544/Script-for-automating-input-on-windows.html

In sasllc's current situation, I realize that this attacks the symptom, not the root cause of the problem. But he says it is a big deal for the customer, resulting in losing scan and weight data, so if I were in his shoes, I'd be tempted to put on this band-aid (which I'm confident will work) while I continued to look for the real underlying cause followed by the real cure for it. But, hey, that's just me. :)  Regards, Joe
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial