[python-win32] Have IHTMLWindow2 objectneed correspondingIHTMLWindow3 object and flash box

Richard Bell rbell01824 at earthlink.net
Fri Aug 3 18:39:18 CEST 2007


I've cleaned up the flash code and am posting it as possibly helpful to
others.

Interestingly, I'm unable to find a way to SetROP2 in win32gui!  So the side
discussion about win32gui v. win32ui may be a bit moot.  If there is a way
I'd be curious to know what it is as it appears to me that there is a
SetROP2 method that is part of window's basic GDI library (but since I'm
definitely not a window's GDI programmer I could well be entirely wrong).

Thanks again for the help.

Regards,
Richard

BTW, the issue of finding the screen coordinates of the HTML tag turns out
to be VERY tricky.  I'm still working on a solution having discovered that
it depends on (among lord knows what other things) the presence of a DOCTYPE
declaration in the page source and nesting of scrollable windows within the
page.  If anyone is interested I'll post a solution when I find one that
actually works.

--- code ---

def flash2(left, top, width, height ):
    """ put a flashing box at cordinates """
    # try to use only win32gui
    from win32con import PS_SOLID, HOLLOW_BRUSH, R2_XORPEN
    # win32gui source
http://pywin32.cvs.sourceforge.net/pywin32/pywin32/win32/src/?pathrev=b208
    hdc = win32gui.GetDC(0)                 # int handle of DC for screen
    hpen = win32gui.CreatePen( PS_SOLID, 3, 0x00ff00)
    hbrush = win32gui.GetStockObject( HOLLOW_BRUSH )
    hpenOld = win32gui.SelectObject(hdc, hpen)
    hbrushOld = win32gui.SelectObject(hdc, hbrush)
    #win32gui.SetROP2(hdc, R2_XORPEN)           # apparently not implemented
in win32gui
    pycdc = win32ui.CreateDCFromHandle(hdc)     # PyCDC object
    pycdc.SetROP2(R2_XORPEN)                    # R2_XOR
    for i in range(0,5):                        # 5 flashes
        win32gui.Rectangle(hdc, left, top, left+width, top + height)    #
draw it
        time.sleep(.250)                        # hang out
        win32gui.Rectangle(hdc, left, top, left+width, top + height)    #
again
        time.sleep(.250)                        # hang out
    win32gui.SelectObject(hdc, hpenOld)         # put back old pen
    win32gui.DeleteObject(hpen)
    win32gui.SelectObject(hdc, hbrushOld)       # put back old brush
    win32gui.DeleteObject(hbrush)
    win32gui.ReleaseDC(hdc,0)                   # release the DC

--- end code ---



More information about the python-win32 mailing list