Jump to content

Dealing with message boxes


Andrew S
 Share

Recommended Posts

Hi, I am looking for a way to deal with message boxes that may pop up in an application. The issue in question is detecting bad files with Adobe Acrobat--Acrobat pops up a message box when this happens. (Reader or Professional)

My current solution is as follows:

1. (with all Adobe Acrobat windows closed) open a PDF file with Acrobat (Run X.pdf in AutoIt)

2. Wait 1 second

3. send alt-f4. This closes any error box.

4. if the Adobe Acrobat window still exists, log this file in an error file and send alt-f4 again

This does an end run around my ignorance of Message Boxes, and it seems to work pretty well, but it is time consuming and makes for awkward code. Obviously if I could just open and close files as needed, checking for message boxes, I could save the overhead of opening/closing Adobe Acrobat.

I didn't find anywhere in the documentation or FAQs or by googling to deal with them. Does anyone have any advice, even if it is just to detect when the main window is not active and there is a popup?

You can reproduce the problem by changing a text file's extension to PDF and opening it, or even, from DOS,

echo random text>xyz.pdf

xyz.pdf

Thanks in advance!

Andrew

Link to comment
Share on other sites

Well doing what you said with a dummy file, this closes the window.

WinClose ("Adobe Reader","Adobe Reader could not open")

I'm not really sure what else your trying to do

Edit... Actually this is better ControlClick ("Adobe Reader","Adobe Reader could not open","OK")

The other method made acrobat hang

Edited by ChrisL
Link to comment
Share on other sites

From AutoIt window info tool:

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Adobe Acrobat

Class: #32770

Size: X: 1305 Y: 306 W: 462 H: 205

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Client: X: 222 Y: -10

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x5574AB Dec: 5600427

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size:

Control ID:

ClassNameNN:

Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Acrobat could not open 'log1.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

To create an Adobe PDF document, go to the source application. Then print the document to Adobe PDF.

OK

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

Make a loop that looks for this window, and have it closed when it shows up. Then have Adobe close if you like.
Link to comment
Share on other sites

Ouch, forgot I logged into these forums and asked this question. Belated thanks to both of you! I hadn't tried any of this before. I tend to get stuck trying the same old functions without learning new ones.

Edited by Andrew S
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...