Get a control over a window

Jürgen Urner jUrner at arcor.de
Tue May 15 15:13:37 EDT 2007


On 15 Mai, 15:06, Tom Gur <gur.... at gmail.com> wrote:
> Hi,
>
> I was wondering how do I get control over a window (Win32).
> to be more specific, I need to find a handle to a window of a certain
> program and minimize the window.


There are many ways to get the handle of  a window.
Assuming you have ctypes at hand, you could try:

>> user32 = ctypes.windll.user32
>> hwnd = user32.FindWindowA(classname, title)
>> if hwnd:
>>     user32.PostMessageA(hwnd, WM_SYSCOMMAND, SC_ICON, 0)

If you need it more acurate you could search MSDN
for how to enumerate all running processes and get the
handles of their windows. Process32First (...) could be
a start for reading.

Jürgen




More information about the Python-list mailing list