WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: sbarthol on February 05, 2015, 12:19:40 PM

Title: WinState not reporting minimize state correctly
Post by: sbarthol on February 05, 2015, 12:19:40 PM
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
Title: Re: WinState not reporting minimize state correctly
Post by: td on February 05, 2015, 01:14:20 PM
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.
Title: Re: WinState not reporting minimize state correctly
Post by: sbarthol on February 05, 2015, 01:25:18 PM
That was precisely the trouble.  Thanks!

Kind of an embarrassing gaffe.   :-[

Title: Re: WinState not reporting minimize state correctly
Post by: td on February 05, 2015, 02:19:51 PM
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.