WinState not reporting minimize state correctly

Started by sbarthol, February 05, 2015, 12:19:40 PM

Previous topic - Next topic

sbarthol

Hi,

I have a short script (below) that's trying to detect if a window is active or minimized, and press a key if active to keep the screen saver from activating.
Everything is great except that the app, when minimized, doesn't report state one.

I suspect that this is due to the app not reporting state correctly, but I'm hoping someone can offer an alternative.  I added the Winposition in case 2, on the hope that the reported position might give me a clue as to what state the app might be in.  It does give me large negative numbers for all coordinates, but they don't seem to be the same on all platforms.

If there's another way to approach this, I'm all for it.  We can't just disable the screen saver entirely for security reasons.

Thanks,

Scott


Run("C:\Program Files (x86)\Polycom\RealPresence Desktop\RealPresenceDesktop.exe","")
windowname="~Polycom RealPresence Desktop"
While WinExist(windowname)
state = WinState(windowname)
Switch(state)
case -1
Break
case 0
Break
case 1
;minimized, don't send anything
case 2
pos = WinPosition(windowname)
Sendkey("{F16}")
Break
case 3
Sendkey("{F16}")
Break
Endswitch
TimeDelay(10)
Endwhile

td

Assuming I have a handle on what you are attempting, it would appear that you are missing a 'break' statement between 'case 1' and 'case 2'.  That omission would cause the behavior as I think you are describing it.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

sbarthol

That was precisely the trouble.  Thanks!

Kind of an embarrassing gaffe.   :-[


td

You are not the first nor will you be the last.  I know I have had more than my share of 'I-can't-believe-I-missed-that' moments.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade