Talking to myself AKA Using Images to determine next step?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Talking to myself AKA Using Images to determine next step?

Post by Tourless » Thu Jun 29, 2017 3:48 pm

Hi Folks,

I'd like to add the ability (assuming it exists) to use pop-up dialogues (as images?) that may be presented during a certain stage of my script to determine the next course of action. At least I think I want to use images unless there is another way to accomplish the same thing.

My script launches QuickBooks and performs an import routine on an array of files found in a given directory. If the import completes successfully then I want to press enter and move on the the next file. So far that works perfectly but it also assumes every import is successful and does not look to the image or window title to determine it's next course, it simply barrels forward blindly. However I need to be able to account for an import failure and would like to log that to a separate file for later review. To take it further from there I'd like an email sent to me with one of three outcomes... completed successfully, completed with errors, or unable to run (completely failed).

In the case of a success, the resulting window that opens is titled 'QuickBooks Information'. If there is an error or a failure the result is a first messagebox titled 'Information' with only a single option (to click OK), followed by a second messagebox titled 'Information' that provides more detail which I would need to have. The later presents two buttons, 'OK' to continue on the current file, or 'Cancel' to abort the import operation. I never want to cancel.

The kicker is I need this to take place within my import loop. I'm not sure if that would mean a nested loop or not (first time even considering it).

Can one of you automation guru's help point me in the right direction here? Should I be trying to work with the window titles and can I extract text from a messagebox, or can I capture and record the messagebox images to preserve the error details? What are my options?

Thanks in advance.

EDIT: I'd also like my error output to include the current file name being processed.

Thanks!
Last edited by Tourless on Thu Jul 06, 2017 4:21 pm, edited 1 time in total.

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Using Images to determine next step?

Post by Tourless » Fri Jun 30, 2017 2:11 pm

Update:
While I've been waiting I've been poking around and found this...
viewtopic.php?f=9&t=4147

After installing MODI it seems to be working to capture the otherwise elusive text where other methods have failed. Both the Image and Text Recognition Wizards failed me, at least I could not get them to work to solve my problem. But I digress...

Now I need to figure out how to say "wait for window... if window title is 'QuickBooks Information' then press enter and move on. If the window title is 'Warning' capture the text and copy it to a log file, then click OK, capture and copy the text of the next window (which will also be titled 'Warning'), then click OK and move on.

I need to learn more about logging... and a few other concepts :) Although for a first run and never using this program before I don't think I'm doing too bad.

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Using Images to determine next step?

Post by Tourless » Fri Jun 30, 2017 3:32 pm

Well I've got the logging enabled, now to figure out how to pass a file name to the log :?

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Using Images to determine next step?

Post by Tourless » Fri Jun 30, 2017 7:32 pm

So I've got WriteLn happily logging my current file name and date/time of process.

Now how do I seek out and act upon one of two possible message windows that can open... WaitWindowOpen or GetFocusedObject with an if/then doesn't seem to be doing the trick... I wonder what will.

Tourless
Pro Scripter
Posts: 69
Joined: Wed Jun 14, 2017 1:53 am
Location: NY

Re: Using Images to determine next step?

Post by Tourless » Fri Jun 30, 2017 9:03 pm

I've got a GetActiveWindow with an If>title= working and returning the expected message but can I nest an If statment inside another If statement?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts