Forum Discussion

sindhu10's avatar
sindhu10
Contributor
6 years ago
Solved

How to check WinformsObject Exists or not

Hi,

i am trying to check WinformsObject exists or not but the  below code is not working 

if(Sys.Process.WaitWinFormsObject("DisplayScheduleMessage").Exists)

{

   Sys.Process.WinFormsObject("DisplayScheduleMessage").Close();

}

else

{

   Log.Message("Window doesnt exists continue next step");

}

 

Please advise.

 

 

Thanks,

  • sindhu10's avatar
    sindhu10
    6 years ago

    Thanks!

    i tried the below code and its working.

    var w = Sys.Process().WaitWinFormsObject("DisplayScheduleMessage", 1000);

    if(w.Exists && w.VisibleOnScreen)

    {

    }

    else

    {

    }

5 Replies

    • sindhu10's avatar
      sindhu10
      Contributor

      Thanks and even i tried giving wait , but its not working

       if(Sys.Process("*").WaitWinFormsObject("DisplayScheduleMessage", 1000).Exists)

       {

         Sys.Process("*").WinFormsObject("DisplayScheduleMessage").Close();

       

      }

      else

       {

         Log.Message("Programme assigned");

       

      }

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Keep in mind that Sys.Process('*') will return the first process it finds in the search... which may not be your application.  You need to specify what process in order to detect the Winform.

         

        Also... you say, "It's not working"... can you be more specific?  What is happening? Any errors? What's in the log?