Jump to content

Error handling


 Share

Recommended Posts

Hello All

I have to do an automation task which will repeat in a loop for the set number of count. This code is working properly.

Now the problem is that, sometimes an error window pops up. So I need to click OK on the error window.

The popping is extremely random. Sometimes it may not pop even after 20 cycles of execution, or sometimes it can pop 2-3 times in the same cycle.

 

Can anyone please suggest a basic format so that:

  • My code runs normally for the set number of cycles, if no error window pops at all during the entire execution
  • Whenever the error window pops, the code should click on its OK button and then return back to the execution of the main code. There should not be any pausing or abrupt termination of the main code.

 

Please suggest some basic structure or some special function or command names which can help achieve this.

 

Thanking in advance

 

Link to comment
Share on other sites

Welcome to AutoIt and the forum!

Which program do you automate? Most programs have an API to allow automation.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for replying.

I know about WinExists and ControlClick.

 

But problem is I cannot put it straight forward in my code because the Error Window pops up randomly at any point of the code.

The most crude way will be to write this "IF block" after each and every line of the code, which is definitely not the thing to do.

I need something based on TRY CATCH.  Correct me if I am wrong.

I am not able to get the proper structure and format for it.

 

Link to comment
Share on other sites

2 minutes ago, Floops said:

I see, what about AdlibRegister() ? Might not be the prettiest solution but it's better than putting an if-statement on every line.

Oh .. never heard of this function before.

I will check in Help about this function in detail.

 

But why did you say that it is not the prettiest solution. Are you aware of any drawbacks of it which I need to take care of ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...