Tuesday 15 July 2014

winapi - Looking for an alternative to the WaitForInputIdle function, available at any time -


I am working on an automation program, and the WaitForInputIdle function helps me determine The problem is that when the window target app is started the problem is that, in my case, it works only with the first window - this is how WaitForInputIdle works, only once.

The functionality of WaitForInputIdle can be implemented in a different way, as the target process is busy every time, and can wait until it is done ?

I thought about posting a dummy message, but I do not think

edit: I came up with some, an ugly and hacked solution that seems to work :

  RECT RC; If (GetUpdateRect (hWnd, & amp; RC, FALSE)) {rc.left = rc.top = 0; Rc.right = rc.bottom = 1; Invalid note (hwnd, and rc, wrong); } Do {sleep (100); } (GetUpdateRect (hWnd, & amp; RC, FALSE));   

I hope that something better than this.

Edit: sending WM_NULL , As suggested by Raymond Chen , works for me.

It looks like PrintWindow hack has no advantage, because internally it sends only WM_PAINT

Older message: I came up with a solution to solve my problem, still a hack but is not ugly.

This idea is misusing the PrintWindow function, which basically sends a WM_PAINT message to Post and waits for action on the window. For - what I really want is a code below with some informational comments.

It was tested on Windows XP and Windows 8 and works as expected, i.e. does not fail despite the zero HDC value.

  // BEWARE: The hack / printwondo below is used as a synchronization tool here. When it says, the system sends WM_PAINT and waits for it to be processed Note: If HWND is hanged, then the following call will hang well PrintWindow (hWnd, NULL, 0);    

No comments:

Post a Comment