650Re: Waiting for application response - GOT IT!
- Nov 16, 2004Hi,
For detailed explanation of the meaning of a function I have used you
should go to msdn.microsoft.com. The details sufficient (hopefully)
to understand my code goes below:
my $get_handle = Win32::API->new
( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
my $proc_handle = $get_handle->Call( 0x001F0FFF, 1,
my $get_idle = Win32::API->new
( 'User32', 'WaitForInputIdle', 'IN', 'N' );
$get_idle->Call( $proc_handle, 20000 );
Win32::API module is used. Its main purpose is to allow you to
call any (almost any?) function from a given dll.
Let's now go to the end. WaitForInputIdle (quoting MS docs) "waits
until the specified process is waiting for user input with no input
pending, or until the time-out interval has elapsed.".
WaitForInputIdle needs a process handle. Process handle is not PID!
In order to get the process handle you have to "attach" to it. You do
it by calling OpenProcess. It takes 3 parameters - access rights,
indicator if handles can be inherited (whatever this means) and PID.
0x001F0FFF in my code means full access, 1 means true (I don't know
if the second parameter of OpenProcess really matters in my
expample). 2868 is process's PID.
So let's rephrase it:
OpenProcess gives the process handle. Using that handle you can check
if the process is ready for input.
In order to make it really usable geting PID of tested application
has to be implemented. And I believe I know how to do it - function
GetWindowThreadProcessId may help. I tried to call it with Win32::API
but it did not work. So I think the best way is to code it in
GuiTest.xs module. I will try to show you the final solution next
Last question - how reliable it is?
Well it works for my case - this is the only think I can tell for
sure. I am not a Win32 programming guru, so I can't tell you that
from the theoretical point of view it is always going to work. I
think we have to give it a try and see how it behaves in different
--- In firstname.lastname@example.org, Darren Blee <d_blee@y...> wrote:
> Wow - what a fantastic solution.
> So basically your waiting for the on_idle event.
> Let us know how reliable it is..
> Do you have time for a more detail explaination of the
> code or maybe a reference?
> Either way I'll be using this code myself - thanks!
> - Darren
> --- pkaluski <pkaluski@p...> wrote:
> I think I found what I needed (it works for me):
> (I apologize if an indentation is bad)
> my $get_handle = Win32::API->new
> ( 'Kernel32', 'OpenProcess', 'NIN', 'N' );
> my $proc_handle = $get_handle->Call( 0x001F0FFF, 1,
> 2868 );
> my $get_idle = Win32::API->new
> ( 'User32', 'WaitForInputIdle', 'IN', 'N' );
> $get_idle->Call( $proc_handle, 20000 );
> Explanation of magic numbers:
> 0x001F0FFF - access rights
> 2868 - PID of tested application
> --- In email@example.com, "pkaluski"
> <pkaluski@p...> wrote:
> > Hi,
> > Thanks for the response. I am afraid that
> IsWindowEnabled is not
> > going to help me. To my knowledge based on some
> > IsWindowEnabled returns control's property, which
> decides if the
> > control should or should not accept input. It does
> not give you
> > information that control is not able to accept any
> input because
> > the application is busy doing something else.
> > --Piotr
> Yahoo! Groups Sponsor ADVERTISEMENT
> Yahoo! Groups Links
> To visit your group on the web, go to:
> To unsubscribe from this group, send an email to:
> Your use of Yahoo! Groups is subject to the Yahoo!
> Terms of Service.
> Find local movie times and trailers on Yahoo! Movies.
- << Previous post in topic