[python-win32] Child Windows

Tim Roberts timr at probo.com
Tue Apr 8 23:53:40 CEST 2008


João Abrantes wrote:
> Hello,
>
> I am trying to make a program that sends text to notepad using 
> win32api.SendMessage function. The thing is that I don't know how to 
> get the notepad child window edit handler and I can't find any 
> documentation about win32 (python) can you help me?

Mark Hammond wrote a book on using Python with Win32.  Google has lots 
of information about it.  In large part, however, you are expected to be 
pretty comfortable with the Win32 API, and if you are, then figuring out 
the Python translations isn't that hard.

In the meantime can use win32api.FindWindow.  The "edit" within Notepad 
had control ID 0x0f.  So, start up an empty Notepad.  Then:

    import win32gui
    import win32con
    notepad = win32gui.FindWindow( None, "Untitled - Notepad" )
    npedit = win32gui.GetDlgItem( notepad, 0x000f )
    win32gui.SendMessage( npedit, win32con.WM_SETTEXT, 0, "Testing" )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list