win32event.WaitForInputIdle() returns too soon

H

Hans

Hi all,

I'm sending keyboard and mouse events to a seperate windows application.
I use win32event.WaitForInputIdle() before calling e.g.
win32api.keybd_event()
However it seems that WaitForInputIdle() returns too soon because some of my
events get lost. Now I'v created my own WaitForInputIdle() which calls the
one
in win32event() and adds an extra sleep(0.1). As expected, this isn't
robust.

Is this a known issue of win32event.WaitForInputIdle() ?
Is it a Windows issue?
Is more involved (but not documented in the Python docs)?
Any ideas?

Thanks
Hans
 
G

Gabriel Genellina

I'm sending keyboard and mouse events to a seperate windows application.
I use win32event.WaitForInputIdle() before calling e.g.
win32api.keybd_event()
However it seems that WaitForInputIdle() returns too soon because some
of my
events get lost. Now I'v created my own WaitForInputIdle() which calls

From the Microsoft docs for WaitForInputIdle: "The WaitForInputIdle
function only works with GUI applications. If a console application calls
the function, it returns immediately, with no wait."
A typical Python script is a console application.
 
H

Hans

Gabriel Genellina said:
From the Microsoft docs for WaitForInputIdle: "The WaitForInputIdle
function only works with GUI applications. If a console application calls
the function, it returns immediately, with no wait."
A typical Python script is a console application.

It would explain my problem.
Perhaps I could create a small windows application as interface..
I have to think about it ( and wait, as I currently don't have access to
visual C++, nor the MS documentation)

Thanks,
Hans
 
K

kyosohma

"Gabriel Genellina" <[email protected]> schreef in bericht




It would explain my problem.
Perhaps I could create a small windows application as interface..
I have to think about it ( and wait, as I currently don't have access to
visual C++, nor the MS documentation)

Thanks,
Hans

Who says you have to create it with Visual C++? You could use Tkinter
or wxPython. Both are pretty easy to pick up and can look professional
with a little work.

Mike
 
H

Hans

<[email protected]> schreef in bericht
"Gabriel Genellina" <[email protected]> schreef in
bericht




It would explain my problem.
Perhaps I could create a small windows application as interface..
I have to think about it ( and wait, as I currently don't have access to
visual C++, nor the MS documentation)

Thanks,
Hans

: Who says you have to create it with Visual C++? You could use Tkinter
: or wxPython. Both are pretty easy to pick up and can look professional
: with a little work.

: Mike


Nobody.
However, yesterday I tried wrapping my piece of offending code into a very
simple Tkinter application.
Alas, the problem wasn't solved. WaitForInputIdle() returns too soon
(unless I don't understand WaitForInputIdle(), which is actually a Microsoft
call.
Therefore using Visual Studio is sometimes handier: doc available and most
compatible with Microsoft's quirks)

Any other suggestions are welcome.

Cheers, Hans
 
H

Hans

Gabriel Genellina said:
From the Microsoft docs for WaitForInputIdle: "The WaitForInputIdle
function only works with GUI applications. If a console application calls
the function, it returns immediately, with no wait."
A typical Python script is a console application.

Well, this is weird. I searched for doc on the internet and that description
differs:
The process you're waiting for needs bo have a message queue (it does in my
case), not the process that calls WaitForInputIdle.
Hans

Waits until the specified process is waiting for user input with no input
pending, or until the time-out interval has elapsed.

DWORD WINAPI WaitForInputIdle(
HANDLE hProcess,
DWORD dwMilliseconds
);
Parameters
hProcess
[in] A handle to the process. If this process is a console application or
does not have a message queue, WaitForInputIdle returns immediately.
dwMilliseconds
[in] The time-out interval, in milliseconds. If dwMilliseconds is
INFINITE, the function does not return until the process is idle.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top