Jump to content

General automation question


Recommended Posts

Hi all,

I'm new to AutoIt and loving it!

I'm trying to automate some processes in a third-party application.

The application is pretty lamely based on a combination of pseudo-HTML and VbScript.

So far I have been extremely happy with everything I have been able to accomplish through the use of AutoIt.

When I was having difficulty trying to interact with the app by directly accessing controls, I found that

AutoIt came to the rescue whereby I could still get control by using MouseMove and MouseClick.

Evidently the application isn't really creating the dropdown lists and buttons that I can see.

Everything is being rendered within the windows as PictureBoxes.

Anyway, enough of that.

I'm looking for anyone who can suggest a way to use AutoIt when I have the following situation:

When I click a button, normally the application goes off and does some processing which includes creating an export file.

I have been watching in my AutoIt script with a WinWait function for the screen changes that indicate that the processing is complete.

However, if the export file already exists, the application stops to ask if I want to replace the existing file.

How should I structure my script so that I can WinWait for two possible outcomes?

Do I need to learn about how to set up and handle events?

Or should I WinWait in a loop with a timeout so that I can occasionally look for the replacement question?

What would I do differently if I had more than 2 possible outcomes that could happen at the same time?

Thanks,

Ken

Link to comment
Share on other sites

  • Moderators

pseudo code:

While 1
    If WinExists("Window Name") Then
        ; Do your window thing here
        Exitloop
    EndIf

    If FileExists("ExportFile") Then
        ; Do export file stuff here
        ExitLoop
    EndIf
    Sleep(250)
WEnd

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Click the button, then do an AdlibRegister() of a function that tests for the popup dialog and handles it if it exists. This will work while WinWait() waits for the completion window. Don't forget to AdlibUnRegister() when you don't have to watch for that dialog anymore.

:)

Edit: Or, you could go with SmOke_N's method and take -1 to Geekiness! :idea:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

You could also change the odds in your favour, if you dont want to see the 'export file already exists' delete it or move it elsewhere before clicking on on the button, if you wanted to always see it, create a dummy version of the export file if it does not exist.

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

Wow, I like all of those answers.

Yoriz, I haven't been able to figure out what variables go into constructing the export file name yet, or if I can get access to them.

But, I agree in thinking that solving a problem before it becomes one is the way to script things.

SmOke_N, yours is like what I was thinking but with a Sleep instead of WinWait timeout.

But, I really like Penguin's answer because it will give me a good excuse for spending time learning about Adlib.

Thank you all very much, and such a quick response time, too!

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...