Detect if win visible but not focused

Started by cssyphus, July 06, 2025, 08:09:28 AM

Previous topic - Next topic

cssyphus

Is there any way to detect if a window is visible but not focused on the screen?

I have a script that watches for a certain condition and, if "SomeApp" is running it does procedure A and if "SomeApp" is not running, it does procedure B.

The problem is that when SomeApp finishes running and is closed, it doesn't really close - so winExist() will still find this program running, even though it is "closed".

For my purposes, all I need to know is if SomeApp is visible on the screen - regardless whether or not it has the focus.

The SomeApp in question is OBS Studio. If it is recording, I do not want Procedure B to run.  When it is recording, the focus may be on OBS Studio, or it may be on the window that is being recorded - but OBS Studio is almost always fully visible on monitor 2 (which is good enough for me... this is not an application where perfect perfection is required - good enough is good enough).

Can anyone think of a way (or did I just forget how...) to detect if OBS Studio is visible on any monitor, regardless if it has the focus or not?

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

cssyphus

AppExist does the trick. Thanks Tony.

Question: if the app is not running, AppExist responds after 5 seconds - but only takes ~ 1 sec if the app is running. Is there a way to change that timeout? Two seconds would work for me, since speed is more important than 100% accuracy in my use case.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

QuotePlease follow the link, paying attention to the function's 3 parameter.

https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILAK_A__005.htm

Clicking that line produces:

This site can't be reached
docs.winbatch.com's server IP address could not be found.

DNS_PROBE_FINISHED_NXDOMAIN

(My network connection is otherwise just fine, so don't assume the problem is on my end)

td

Works fine for me and no one else is complaining.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

snowsnowsnow

QuoteWorks fine for me and no one else is complaining.

Seems to be a problem with my (specifically, my ISP's) DNS.  Everything else works fine, but pinging docs.winbatch.com fails.

It turns out both forum.winbatch.com and docs.winbatch.com fail my DNS and have to be explicitly listed in the hosts file in order to work.

Putting this line in the hosts file fixes things:

68.178.202.14   forum.winbatch.com docs.winbatch.com


SMF spam blocked by CleanTalk