Intercepting spooler timeout  messages

_ecpirosis_
_ecpirosis_ used Ask the Experts™
on
Hi Experts,
I have an unattended printing process on w2k sp4. When the printer goes down a popup asks if retry or cancel the job.
The best would be  intercept the message, cancel the job, write a log and then reset the state.

The lowest level of the solution would be avoid the user message triggering a predefined condition such as delete job.

Do you know a way to achive this?
 
Thank you in advance for every suggestion
Francesco

The interactive error message that should be intercepted
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
you could try to call FindWindow (for example in an infinite loop and so get a handle of the message window:

while (1)
{
   Sleep(1000); 
   HWND hwnd = ::FindWindow(NULL, "Cartella Stampanti");
   if (hwnd != NULL)
   {
     PostMessage(hwnd, WM_CLOSE, 0, 0);
   }
   // here ad some code that you could stop the loop
}

Open in new window


if closing the message box is not the required action, but to click one of the buttons, things are more difficult since messages to buttons or controls only can be issued by the process (thread) that owns the message box.

the only way to achieve that is by a global hook. that is a dll which needs to be registered (admin rights required) and then was able to hook into the message queue of any process what would allow to find out when the message box was initially shown and then could click on a button programmatically.

Sara

Author

Commented:
Hi Sara, thank you for the answer.
Some details: the message is not generated from an interactive application (as far I can understand) but from the spooler process itself (spoolsv.exe).
I am going to try your solution.
Thank you very much for the direction
Francesco
I've requested that this question be closed as follows:

Accepted answer: 500 points for sarabande's comment #a40863084

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Author

Commented:
Thank you Sara, it works.
Francesco

Author

Commented:
I apologize for the delay.
Francesco

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial