[python-win32] win32ui and flashing box

Richard Bell rbell01824 at earthlink.net
Thu Jul 26 23:53:04 CEST 2007


I'm a complete neophyte when it comes to window's GUI and need a bit of
help.

I'm working on an application that automated IE and want to draw a flashing
box around screen elements.  I can find the coordinates OK but am a bit
unclear on how to actually draw a box in such a fashion that when the
flashing stops the screen is as it was before it started.  A bit of
investigation suggests that something like this ought to work:

import win32gui, win32ui
def box(hdc, x, y, w, h):
    hdc.MoveTo(x, y)
    hdc.LineTo(x+w, y)
    hdc.LineTo(x+w, y+h)
    hdc.LineTo(x, h+h)
    hdc.LineTo(x, y)

hdc = win32ui.CreateDCFromHandle(win32gui.GetDesktopWindow())
box(hdc, 200, 200, 200, 200)

But when I run the code I get a win32ui: LineTo failed exception.  Is there
a simple way of doing this?



More information about the Python-win32 mailing list