cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine if an IE browser window is maximized, minimized etc...

JohnMonastra
Level 3
Hi. I am needing to know the window state of an application that is running in an IE browser. I figured I could use a Reader and "Get Window attribute", but, no luck so far. Any ideas? Thanks, John
2 REPLIES 2

DaveMorris
Level 14
Hi John, I have to ask. What's the scenario for your getting the state of the window? Would it be enough to just set it to be maximized, minimized, etc.? I assume you've seen the actions available in a navigate stage. I usually spy the entire window in Win32 mode and then I run the action to maximize before doing anything else. I haven't done it in a few months, but if I remember right, maximize works whether it's already maximized or not. Disclaimer: I'm just giving a suggestion of the top of my head. I did not look into this much and I've never needed to do this. So, I'd ask around to verify there isn't already a way to do this. For example, there may be .NET code you can run to precisely get the state of the window. I feel like I've seen this somewhere, but I just can't remember. So here's an idea below that popped into my head. =) If you do really need to know the current state of the window, I'm not aware of an existing action that simply returns 'maximized', 'minimized', etc. It could be hiding somewhere, but I don't see it. So, if you need to come up with your own action for this, consider using the Environment VBO to get the current resolution, use the read stage (as you were saying) to get the width and height of the window, and then compare. I just tested this and it doesn't seem to be perfect but it's close. I did three tests, on each getting my horizontal screen resolution and getting the width of the window using a read stage using 'Get Window Attribute' with an Attribute Name of 'Width'. First: I made my window normal (not maximized) so that it was only taking up part of the screen. The window width came back as around 1000 and the horizontal screen resolution was 1920. So, while this doesn't tell me for sure that the window isn't minimized, it does tell me it is for sure not maximized. Second: Then I made my window maximized. After running again, the window width came back as 1937 and the horizontal screen resolution was 1920. So, as I said, it's not perfect. You'd need to give it a tolerance number to use. However, I suspect that (assuming I'm right that there's not an existing action for this and I really hope there is and I'm just missing it) you could play around with retrieving these different values and comparing them. Third: I minimized my window and ran it again. This time the window width came back as 161 and the horizontal resolution of course was 1920. What I take from this is that you could make a reusable action that returns the state of the window based on those values. As I see it, I'd have it return Maximized if the width is over 1900, Normal if it's between 200 and 1900, and Minimized if it's under 200. This is of course assuming you have a resolution of 1920x1080. Dave
Dave Morris 3Ci at Southern Company Atlanta, GA

SteveNarkis
Level 2
16815.png
​John,

Maybe not exactly what you want, but I have been successful in spying for the Maximize button at top right of the browser window. As a button (UIA) it has the name Maximize or the name Restore depending on which state the window is in at that time. Use Verify from Navigate stage to know which button is present.

------------------------------
Steve Narkis
Consultant
Avanade
------------------------------