Python 2.0b2 (#6, Sep 26 2000, 14:59:21) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import win32gui
>>> win32gui.FindWindow("","dog")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
pywintypes.api_error: (123, 'FindWindow', 'The filename, directory name, or
volu
me label syntax is incorrect.')
Thanks
--Darrell
I can't make it work either. It's not clear from the docs how to specify a NULL for the first arg -
which is what I think you need. I tried 0 and None but both crash Python.
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants
> I can't make it work either. It's not clear from the docs how to specify a NULL for the first arg -
> which is what I think you need. I tried 0 and None but both crash Python.
None as the first param is indeed passing NULL to the API - the API is
what is crashing with that NULL :-( Indeed the API documentation does
not state NULL is OK.
>>> win32gui.FindWindow("ConsoleWindowClass", "Command Prompt")
131402
The class name can be determined from spy++.
Mark.
FindWindow is not documented in the Win32 API's to support NULL as
a first parameter.
EnumWindows is what I'd use to find windows of any class in C or C++,
but I don't know, offhand, if win32all exposes it...
Alex
>"Dale Strickland-Clark" <da...@out-think.NOSPAMco.uk> wrote in message
>news:q05p0told569nfa8m...@4ax.com...
> [snip]
>> I can't make it work either. It's not clear from the docs how to specify a
>NULL for the first arg -
>> which is what I think you need. I tried 0 and None but both crash Python.
>
>FindWindow is not documented in the Win32 API's to support NULL as
>a first parameter.
I was going to give you a big "HUH?" in response to this, but I see that
the MSDN web page on FindWindow does not explicitly state that NULL is
allowed for the class name. This is a documentation failure, not an API
restriction: the MSDN web page is incomplete. NULL is a valid option for
either parameter to FindWindow, and specifies that the option is not to be
used as a criteria in the search. It has always worked, and it will
continue to work.
The page on CWnd::FindWindow says this explicitly:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcmfc/_mfc_cwnd.3a3a.findwindow.htm
and CWnd::FindWindow is implemented as an inline call to FindWindow.
Microsoft uses the NULL first parameter in their examples; see knowledge
base article Q124103.
Dale correctly pointed out the problem; he needs to pass a NULL, not a
zero-length string. I don't know how to do this, either.
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
> Dale correctly pointed out the problem; he needs to pass a NULL, not a
> zero-length string. I don't know how to do this, either.
And I pointed out that None does indeed pass a NULL.
A quick test showed me that it was the Win32 FindWindow function that
failed on dereferencing NULL, so I was too quick to point the finger. I
didn't look closely enough - this is a bug in win32gui. The annoying
thing is that Pythonwin uses the exact code the KB article pointed at,
so I should have known better.
Mark.