tags:

views:

46

answers:

1

Hi all -

I have a third-party GUI program that I'm wrapping with a Python class (using ctypes).

Are there Win32 API functions that can do the following?

1) Obtain the window handle for a window at a given screen location.

2) Obtain the window handle for a Button or Static window with a given caption.

3) Send text to an Edit window.

4) Extract text from a RICHEDIT instance.

I have WinSpy (a Spy++-type app) and know that it's possible to obtain window handles and captions using that tool, but I need something that works within Python.

I assume that Python's ctypes gives me access to any function within the Win32 API, so I've been scanning MSDN (especially this windows/messages section). I can't seem to find anything that works.

Thanks,

Mike

+2  A: 
  1. WindowFromPoint

  2. FindWindowEx to find a child of a window with a given class and name (caption). Repeat operation to get through each parent-child indirection. EnumChildWindows can be helpful too.

  3. SendMessageTimeout + WM_SETTEXT

  4. SendMessageTimeout + WM_GETTEXT or EM_STREAMOUT

adf88