"fraca7" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hello. I got a little problem while using pythoncom to automate IE; for some 
> reason, changing the 'selectedIndex' on an 
> instance of IHTMLSelectElement doesn't fire the 'onchange' event (I guess 
> this is a bug in mshtml).

As I understand it, this was done as a security measure to foil script
exploits.

> So, I tried to get the 'onchange' event handler and call it myself. According 
> to the docs, this is a simple IDispatch 
> implementation and calling Invoke() should do the trick; I actually have a 
> working example of this in Delphi.
>
> But I can't manage to get it work in Python; the following code
>
>
>         idisp = pythoncom.WrapObject(elt.onchange)
>         idisp.Invoke(pythoncom.DISPID_VALUE,
>                      0x400, # LOCALE_USER_DEFAULT
>                      pythoncom.DISPATCH_METHOD,
>                      False)
>
> fails with an AttributeError:
>

You can access the underlying IDispatch using the
_oleobj_ property, ie elt.onchange._oleobj_.Invoke(......)

Alternately, you can also use FireEvent, which would look
something like this (untested):
elt.FireEvent('onchange',elt.onchange)


           Roger



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to