Jump to content
Sign in to follow this  
undoo

Close error message from an application.

Recommended Posts

undoo

Hello everybody,

This might be a simple question for some of you but i tried a few solutions myself and they didn't work. So here it goes:

I have to run a report using a tool that causes some errors along the way. The errors don't affect the output, but they stop the generation until someone goes and clicks on "OK" on that popup. Considering that this report can take a few good hours to finish, it's kind of hard to leave it over night so i need something to close that windows every time it pops. The name of the error window is just "Error" and some of the text says: "Encountered a COM error".

I tried making a script to run the report generation from the CMD then by using WinWaitActive and WinWait (the popup isn't always active or on top) i tried to Send "OK" or WinClose/WinKill. I can't seem to make it work. I'm not sure if i'm doing something wrong. Any suggestions? Thanks :)

 

Share this post


Link to post
Share on other sites
orbs

for Send() you must make sure the Windows session is not locked while the report is generated. if this is an issue, try to use ControlSend() instead.

post your code so we can see if there's anything dreadfully wrong with it.

Share this post


Link to post
Share on other sites
TheSeeker

You can probably try to make the error massage on top by focusing it, but for that you need to know the id of the window, which you can find using AutoIT window info tool. (comes with autoIT, located in the installation dir). Then you can focus it using winactivate() and then send {ENTER}


"Let me win[color=rgb(68,68,68);font-family:arial, sans-serif;font-size:small;], [/color]but if I cannot[color=rgb(68,68,68);font-family:arial, sans-serif;font-size:small;] win, let me be brave in the attempt"[/color]

Share this post


Link to post
Share on other sites
TheSaint

Are these error messages you create yourself?

If so, then you can add a wait parameter (in seconds) to your MsgBox.

Or system ones?

In which case, if all error message windows are titled "Error", then you could use that as the title for WinClose, but adding the text too, will make it more accurate and specific.

If needed, create a log file of the errors, so you get time and error text, which may help with the System errors for the text element, when trying to improve your program. I'm guessing you will only ever (normally) get certain errors?

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
undoo

Hey guys, thank you for the prompt reply.

@orbs: i tried to use SendControl but it doesn't seem to make a difference. there is not much of a code, but here are some of the things i tried:

run("B:RhapsodyRhapsody_7612reporterplusreporter.exe /m D:CASDEVcmsynergyuid6510zCCM_WACSP_WZAssetRepository-uid6510zAssetRepositoryAssetRepositoryAssetRepository.rpy /t D:usersuid6510zDocumentsTemplatesExtractAssetRepository.tpl /ft txt /fn D:usersuid6510zDocumentsExtractAssetRepositoryExtractAssetsTest.csv /q yes") // command line that launches the document generation
 
1.WinActivate ("Error", "COM error")
   Send ("{ENTER}")
2.WinClose("Error", "COM error")
3.WinWait("Error", "COM error")
   ControlSend("{ENTER}") or with Send ("{ENTER}")
 
Am i doing something wrong?
 
@The Seeker: Tried it as you can see above but without any help.
@The Saint: The error messages are from the reporting tool. I'm getting only one kind error that pops-up several times at random moments of the loading process.
 
Later edit: One more question: If this error shows up a few times should i use a loop function so it closes them each time? or the application does that by default each time it finds a windows with that name?
Edited by undoo

Share this post


Link to post
Share on other sites
TheSaint

Have you tried without the text - "COM error"

I'd be using MsgBox reports to test for things.

I'd have everything running in a continuous loop while the Reporter tool is running, but give your program an escape to quit the loop. That last for me, would be something like a floating STOP button or other minimal GUI (could also be a Hotkey via the _IsPressed command), plus regular testing that the Reporter.exe process is still running. The loop would have appropriate SLEEPS to minimize processor usage.

Some of the loop commands, I would have, is

While 1
     If WinExists("Error", "COM error") Then
          WinActivate("Error", "COM error")
          WinWaitActive("Error", "COM error", 9)
           If WinActive("Error", "COM error") Then
               Send("{ENTER}")
          EndIf
     ElseIf Not ProcessExists("Reporter.exe") Then
          ExitLoop
    Else
         ; other code here to manually exit
     EndIf
     Sleep(500)
Wend

If ENTER is not working for you, then you may need to get the position of the Error dialog (WinGetPos), and use a mouse click at the determined coordinates. Avoiding your Mouse, does the Error dialog close manually for you using your ENTER key? If not, then it is possible it works for another key (i.e. SPACE) or some other accelerator key.

You could also try using the WinKill command.

EDIT

Oops, got interrupted and forgot to check the WinPos command. I wasn't gonna logon tonight, but that possible error popped into my head, so I thought I better check and make any necessary correction.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
undoo

Thank you for your advice The Saint, but unfortunately it didn't work. However, i' ve found another solution to avoid this error. Thanks alot for your help. 

Share this post


Link to post
Share on other sites
TheSaint

If it is a coded solution, then you really should share, as it may help someone else.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
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
Sign in to follow this  

×