Forum Discussion

Dhana's avatar
Dhana
Contributor
13 years ago

IE Full Screen function

Hi, I need to check whether my appication which get opened with IE is in Full Screen mode or is in Maximize state.



For this, I used Object Spy to check the properties that are getting differ while the IE window in Full Screen mode as well as in Maximize state, since there is no direct function for checking the IE whether is in Full Screen mode or not.



Now, I found that Focused is a property where it get differs in both, when the Focused property is set to False, IE is in maximise state and when it is True is in Full Screen mode. So, I got an idea to get a boolean value by setting a Focused property with my object from my script, this is what my requirment.



My Queries:



1) Is there any data type should I use to get an boolean value? 

e,g: Var variablename = TestObj.Focused; ( will this work in my case)

2)  if..then is not working in this case..Why?



Please get me an solution for it.

2 Replies

  • I tried the below code in my script,



    var r = Sys["Process"]("IEXPLORE")["Window"]("IEFrame", "ChartAnnotation - Windows Internet Explorer", 1)["Window"]("Frame Tab", "", 1)["Window"]("TabWindowClass", "ChartAnnotation - Windows Internet Explorer", 1)["Window"]("Shell DocObject View", "", 1)["Window"]("Internet Explorer_Server", "", 1)["Window"]("MicrosoftSilverlight", "", 1);      // obj name

    varBoolean w =r["Focused"]           //scripts throws error in this line, saying " ; " expected

    if (w = true)

    Log["Message"]("FullMode");

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Dhanalakshmi,



    Hi, I need to check whether my appication which get opened with IE is in Full Screen mode or is in Maximize state.


    To check whether the browser window is maximized, I recommend using the following function to which you should pass the browser window (the IEFrame object) as a parameter:

    function IsMaximized(Window)

    {

      return ((Window["WndStyles"] & Win32API["WS_MAXIMIZE"]) == Win32API["WS_MAXIMIZE"]);

    }



    // Example usage:

    function Test()

    {

      var wmdIE = Sys["Process"]("IEXPLORE")["IEFrame"](0);

      var bIsMaximized = IsMaximized(wmdIE);

      Log.Message(bIsMaximized);

    }


    To check whether Internet Explorer is in Full Screen mode, you can try checking the native FullScreen and TheatreMode properties of the Page object. I'm not sure if this is a 100% solution, but it worked in the scenarios I've tried:

    function IsFullScreen(Page)

    {

      return (Page.FullScreen || Page.TheaterMode); // Note: IE only!!!

    }



    // Example usage:

    function Test()

    {

      var page = Sys.Process("IEXPLORE").Page("*");



      var bIsFullScreen = IsFullScreen(page);

      Log.Message(bIsFullScreen);



      page.Keys("[F11]"); // Toggle Full Screen



      bIsFullScreen = IsFullScreen(page);

      Log.Message(bIsFullScreen);

    }






    Now about your language syntax questions.



    1) Is there any data type should I use to get an boolean value?

    e,g: Var variablename = TestObj.Focused; ( will this work in my case)


    No, you simply use the var keyword to define a variable and don't specify the data type. All script variables are of the so-called Variant type, which means they can hold different data types at different times. For more information about declaring variables in JScript/C#Script, see these MSDN articles:

    JScript Variables

    var Statement





    varBoolean w =r.Focused //scripts throws error in this line, saying " ; " expected


    It errors out on varBoolean; the correct syntax is:







    2) if..then is not working in this case..Why?

    ...

    if (w = true)

      Log.FullMode("");


    In JScript/C#Script, you use a double equal sign == to compare values:



    For boolean values (true/false), you can also use:

    if (w)

      // statements for true

    else

      // statements for false


    A single equal sign = is used for variable assignments. Your original code doesn't work because it essentially sets the w variable to true, and as a result, the condition always evaluates to true.