At Saturday 20/1/2007 21:35, jbd wrote:

I create a process via the CreateProcess function, and i wait using
WaitForInputIdle to be sure that the process is in ready state, it works
well (ie: the process is launched).

Check also whether WaitForInputIdle returns 0, and not WAIT_TIMEOUT (meaning that the process is not ready yet)

I send a message via PostMessage and
i'd like to know if the command had been correctly processed, and i don't
know how to do it.

But, although the application is in ready state, some hardware
initialization has to be done and seems not to be accomplished when
WaitForInputIdle returns. The message i posted using PostMessage is
correctly processed, but nothing appends since the ressource i need were
not yet initialized. If i introduce a time.sleep(2) between the
WaitForInputIdle and the PostMessage function, everything is working fine.

And the sleep isn't an acceptable solution, I presume.
You can use some form of interprocess communication; coming from a Unix environment you may know some of them, like pipes, queues. Or a synchornization mechanism like a semaphore. But since you're already using messages, maybe the easiest way is making the target application broadcast a message telling "I'm ready now", and when the caller sees it, it knows it can post the message. Use RegisterWindowMessage on both applications, with the same name, to obtain a unique message identifier. Use HWND_BROADCAST as the first argument to PostMessage to broadcast it to all top level windows.

On the msdn site, the PostMessage function returns a BOOL, but since this
is an asynchrone function, the return value just means that the message
has been posted without problem. Am i correct ? By the way, how do i check
for this return value with pywin32 ? All message related function seems to
return None.

Yes, it appears that you cannot retrieve the return value of PostMessage. Anyway it won't tell you much. The caller can communicate its own window handle to the target application, using the wParam or lParam arguments when it sends some message. This way, the target application can reply to the caller when he has completed processing the operation (either ok or with an error).


--
Gabriel Genellina
Softlab SRL

        

        
                
__________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to