Intercepting spooler timeout messages

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
_ecpirosis_Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sarabandeCommented:
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
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_ecpirosis_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
0
hdhondtCommented:
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.
0
_ecpirosis_Author Commented:
Thank you Sara, it works.
Francesco
0
_ecpirosis_Author Commented:
I apologize for the delay.
Francesco
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.