ash10
10 years agoOccasional Contributor
Solved
How to check if the window or object exsist
I have dialog1 appearing on my App sometime and if it appears then I have to click on Ok and sometime this dialog might not appear.
if(Aliases["App"]["WinFormsObject"]("Dialog1")["Exists"])
Aliases["App"]["WinFormsObject"]("Dialog1")["WinFormsObject"]("buttonClose")["Click"]()
I cannot us "Exists" property here on Dialog1 as Dialog1 will not be there if it does not appear.
I tried to put try catch block also but it is not handling the expection thrown try catch.
Use WaitWinFormsObject for Dialog1:
var dlg = Aliases["App"]["WaitWinFormsObject"]("Dialog1", 1000); if (dlg.Exists) dlg["WinFormsObject"]("buttonClose")["Click"]();