1

The pop-up box event is a windows error notification with a 'OK' click box. I want to auto-click the 'OK' or suppress the appearance of the pop-up box. But how to capture this event? I can't see anything appearing in event viewer, and i can't track the source of the error (except that originates from excel.exe, which is running a long running process, which occasionally stops unexpectedly when the pop-up box appears).

Other info in the pop-up box includes the following; Microsoft Visual C++ Runtime Error (R6025). On clicking 'OK' the process crashes, which is fine, since at that point i can capture the crash event via windows event viewer, and then run a scheduled task on the back of it (to restart).

The following question is related but different in that i'm simply looking at how to capture and deal with this event, rather than find and fix the cause (link here).

FYI: Running windows server 2012

Yugmorf
  • 135
  • 1
  • 7
  • What is the purpose of this? Are you writing an application? If you explain why it may help us to understand the question better :) – Dave Oct 09 '14 at 07:44
  • @Dave. I have a long running process (essentially calculates some data and writes results to a text file). The pop-up box stops the process running and I have to manually login to rectify it (press 'OK' on the pop-up box, or restart the application). A workable solution would allow me to run a script when the pop-up box appears (that deals with it - eg auto restarts the app), rather than hanging the application until I intervene manually. – Yugmorf Oct 09 '14 at 08:52
  • What language are you doing this in? – Dave Oct 09 '14 at 11:21
  • If possible, then .net or vb script. Is it dependant on the language? – Yugmorf Oct 13 '14 at 04:50

1 Answers1

0

I think you need to use AutoHotKey

It has a timer, meaning you can fire an event every N seconds to check, or, it can detect it natively as well (I think)

#Persistent
SetTimer, MsgBoxCheck, 1000

MsgBoxCheck:
If WinExist("msgboxTitle", "msgboxTextString", "ahk_class #32770")
{
   WinClose
   ExitApp
}

OR

; "Waits until the specified window exists."
; secondsToWait can be omitted. (msgboxTitle/TextString are literal strings.)
WinWait, msgboxTitle ahk_class #32770, msgboxTextString, secondsToWait
if ! ErrorLevel ; didn't time out
    WinClose
ExitApp

Source for both code snippets

Also, a post on StackOverflow has a similar question

Dave
  • 25,297
  • 10
  • 57
  • 69
  • 1
    I'll try that. Thank you. Appreciate your time taken to provide an answer, but unfortunately it seems I can't up-vote you since my reputation is still to low. Thanks all the same. – Yugmorf Oct 17 '14 at 15:08