f



How can Spy++ see windows that GetWindow() can't?

My program is launching another program using CreateProcess(), and
then the launching program needs to control the launched program by
sending it mouse and keyboard events.  Nothing abnormal there.

What is strange, is that the launching program isn't able to find the
correct windows inside the launched program.  Spy++ correctly sees
that the main window of the launched program has 7 child windows,
while both GetWindow(GW_HWNDNEXT) and EnumWindows() report only 4
child windows.

Does anyone know what method Spy++ uses to find its windows?
0
Chris
11/8/2010 6:47:04 PM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

3 Replies
1062 Views

Similar Articles

[PageSpeed] 52

On Nov 8, 6:47=A0pm, Chris Shearer Cooper
<chris.shearer.coo...@gmail.com> wrote:
> What is strange, is that the launching program isn't able to find the
> correct windows inside the launched program.

How quickly after launching the program do you look for them?  I
wonder whether the problem isn't that the child windows cannot be
seen, but simply that they don't yet exist.  I know I've had to use
Sleep, or WaitForInputIdle, or SendMessage(WM_NULL...) to ensure the
launched application has completed its initialisation before trying to
find its child windows.

Richard.
http://www.rtrussell.co.uk/
0
Richard
11/8/2010 10:44:14 PM
On Nov 8, 3:44=A0pm, Richard Russell <n...@rtrussell.co.uk> wrote:
> On Nov 8, 6:47=A0pm, Chris Shearer Cooper
>
> <chris.shearer.coo...@gmail.com> wrote:
> > What is strange, is that the launching program isn't able to find the
> > correct windows inside the launched program.
>
> How quickly after launching the program do you look for them? =A0I
> wonder whether the problem isn't that the child windows cannot be
> seen, but simply that they don't yet exist. =A0I know I've had to use
> Sleep, or WaitForInputIdle, or SendMessage(WM_NULL...) to ensure the
> launched application has completed its initialisation before trying to
> find its child windows.
>
> Richard.http://www.rtrussell.co.uk/

Bingo!

Yes, I was already calling WaitForInputIdle(), and even after that I
was waiting for the main window to appear in EnumWindows(); but I
added some code to check for the number of children, and if they
aren't all there, to wait some more ... and that was it!

I was looking for something difficult, like maybe EnumWindows() didn't
find Unicode windows or something (not that I know the launched
program has Unicode windows), it didn't occur to me that the reason I
wasn't seeing the windows is that they weren't there yet ...

Thanks!
Chris
0
Chris
11/8/2010 11:04:23 PM
On Mon, 8 Nov 2010 15:04:23 -0800 (PST), Chris Shearer Cooper
<chris.shearer.cooper@gmail.com> wrote:

>On Nov 8, 3:44�pm, Richard Russell <n...@rtrussell.co.uk> wrote:
>> On Nov 8, 6:47�pm, Chris Shearer Cooper
>>
>> <chris.shearer.coo...@gmail.com> wrote:
>> > What is strange, is that the launching program isn't able to find the
>> > correct windows inside the launched program.
>>
>> How quickly after launching the program do you look for them? �I
>> wonder whether the problem isn't that the child windows cannot be
>> seen, but simply that they don't yet exist. �I know I've had to use
>> Sleep, or WaitForInputIdle, or SendMessage(WM_NULL...) to ensure the
>> launched application has completed its initialisation before trying to
>> find its child windows.
>>
>> Richard.http://www.rtrussell.co.uk/
>
>Bingo!
>
>Yes, I was already calling WaitForInputIdle(), and even after that I
>was waiting for the main window to appear in EnumWindows(); but I
>added some code to check for the number of children, and if they
>aren't all there, to wait some more ... and that was it!
***
WaitForInputIdle indicates the message pump has blocked.  So without knowing how the child
process manages its windows, there is no way to guess.
			joe
****
>
>I was looking for something difficult, like maybe EnumWindows() didn't
>find Unicode windows or something (not that I know the launched
>program has Unicode windows), it didn't occur to me that the reason I
>wasn't seeing the windows is that they weren't there yet ...
>
>Thanks!
>Chris
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
Joseph
11/13/2010 1:26:46 AM
Reply: