Forum Discussion

ntammadge's avatar
ntammadge
New Contributor
5 years ago
Solved

Overlapping window log error when window has been handled by event handler

I'm currently handing an overlapping window using the project's event handler and after it exits I still get an error in the log. As far as I can tell the object still exists, but it is no longer visible. I was hoping for a way to not post the error to the log because it has been sufficiently handled for my test.

 

For anyone interested in trying to reproduce this:
Open an "older" version of VS 2019 (I'm currently using 16.0.3 with 16.0.4 available) and wait for the toast window in the bottom right hand corner to appear telling you that there's a newer version available.

Create a C# winforms project.

Add a textbox control to the form.

Attempt to interact with any property of the control in the properties window behind the toast window.

You'll generate the overlapping window event.

Inside the overlapping window event handler run

Sys.WaitProcess("devenv", 500).Find("Name", "*HwndSource: ToastWindowRoot*", 5).Find("WPFControlName", "IgnoreButton", 8).Click(); // To click the close button on the window

Delay(5000); // To prove that it's not a timing issue

The toast window object still exists, but doesn't appear on the Visual Studio window. You'll still get an error in the log saying there was an overlapping window.

  • Right... the code for the handler doesn't REMOVE the OverLapping window error, it just handles the overlapping window so it doesn't "blow up" your automation.

    What you need to do, to suppress the message, is that if that object exists and is present, call your code you already have AND add a call to LogParams.Locked = true;

     

    That will suppress the log message while still handling the window.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Right... the code for the handler doesn't REMOVE the OverLapping window error, it just handles the overlapping window so it doesn't "blow up" your automation.

    What you need to do, to suppress the message, is that if that object exists and is present, call your code you already have AND add a call to LogParams.Locked = true;

     

    That will suppress the log message while still handling the window.

    • ntammadge's avatar
      ntammadge
      New Contributor

      Gave that a shot and it worked great. Thanks!