How to capture a windows pop-up box event in task manager or by other method?

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

Posted 2014-09-11T04:40:16.780

Reputation: 125

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 – 2014-10-09T07:44:32.190

@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 – 2014-10-09T08:52:01.937

What language are you doing this in? – Dave – 2014-10-09T11:21:02.190

If possible, then .net or vb script. Is it dependant on the language? – Yugmorf – 2014-10-13T04:50:18.337

Answers

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

Posted 2014-09-11T04:40:16.780

Reputation: 24 199

1I'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 – 2014-10-17T15:08:28.777