Access denied calling FireEvent in Python

calfdog at yahoo.com calfdog at yahoo.com
Mon Mar 28 09:17:34 EST 2005


Found that you have to call FireEvent a different way in the News IE
and  sp2
Instead of:

ie.Document.forms[0].campus.fi­reEvent('onchange')

if needs to be changed to:
ie.Document.forms[0].campus.Fi­reEvent('onchange')


RLM



calfdog at yahoo.com wrote:
> Hello,
>
> Does anyone know a workaround for calling fireEvent.
> With the latest from Microsoft OS XP2 and Hot fixes to
> IE it now gives an "access denied" error in Python when called.
>
> Here is what I am trying to do:
> Set the "campus" listbox value and theb call fire event, such as in
the
> code below.  I get an "access denied" error.
>
> example code:
> ie = DispatchEx('InternetExplorer.Application')
>
> # Some code to navigate to the site, wait till doc is not busy and #
> ReadyState is complete...blah..blah...
>
> ie.Document.forms[0].campus.value = '200'
> ie.Document.forms[0].campus.fireEvent('onchange')
>
> HTML code:
> <select style="font-size: 10" name="campus" onChange="if
> (this.options[this.selectedIndex].value != 0)
> populate(this.options[this.selectedIndex].value)">
> <option value=0>Select a campus
> <option value="200">Norman Campus
> <option value="501">Advanced Programs
> <option value="502">Liberal Studies
> <option value="504">Academic Programs (CAFE)
> <option value="505">OU Tulsa</select>
>
>
> If you call:
> fireEvent('onchange')
> fireEvent('onclick')
> fireEvent('onFocus') etc... You will get an Access Denied
>
> This only happens with either the newer version of IE and XP2.
> I was able to call the exact same code with XP1 and Win2000 Pro
> and it work fine. So something has changed with I.E. and is not being
> handled in Python.
>
>
> example code:
> ie.Document.forms[0].campus.fireEvent('onchange')
>
> Trace:
>  File
>
"C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
> line 310, in RunScript
>     exec codeObject in __main__.__dict__
>   File "C:\QA\Tools\cPAMIE150\oCScript2.py", line 24, in ?
>     ie2.Document.forms[0].campus.fireEvent('onchange')
>   File "C:\Python23\Lib\site-packages\win32com\client\dynamic.py",
line
> 165, in __call__
>     return
>
self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None)
> com_error: (-2147024891, 'Access is denied.', None, None)
> 
> Help would be much appreciated!!
> 
> RLM




More information about the Python-list mailing list