By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,091 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,091 IT Pros & Developers. It's quick & easy.

Win 32 - VB, Ruby, Perl VS Python with fireEvent

P: n/a
Hello,

I was wondering if anyone could tell me why fireEvent works in every
language but Python with the latest Internet Explorer?

I tried this page that has two listboxes if you select Listbox A the
Listbox B should change.

The code status:
Works fine with Python 2.3, 2.4 in Windows XPsp1
DOES not work Python 2.3, 2.4 XP Sp2 or the lastest IE
Works fine with "RUBY" on Win 2000, XP sp1 and XP sp2
Work fine with PERL on on Win 2000, XP sp1 and XP sp2

Luckily I know both Ruby, VB and Perl so I could prove there was a
problem.

Here is the example code in both Python and Ruby:

Python:
from win32com.client import DispatchEx
import time


def wait(ie):
while ie.Busy: time.sleep(0.1)

doc = ie.Document
while doc.ReadyState != 'complete': time.sleep(0.1)

ie = DispatchEx('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate( 'https://enroll.ou.edu/' )
wait(ie)
ie.Document.forms[0].campus.value='200'
ie.Document.forms[0].campus.fireevent('onchange')

Results:
Traceback (most recent call last):
File
"C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\automation\poScript1.py", line 18, in ?
ie.Document.forms[0].campus.fireevent('onchange')
File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line
154, in __call__
return
self._get_good_object_(self._oleobj_.Invoke(*allAr gs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147024891, 'Access is denied.', None, None)

Ruby:
# OU Registration & Enrollment Online
require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome
ie.navigate('https://enroll.ou.edu/')
while ie.busy
end

READYSTATE_COMPLETE = 4
until
ie.readyState == READYSTATE_COMPLETE
end
form = ie.document.forms(0)
form.campus.value = '200'
form.campus.fireevent('onchange')

Results: fireEvent was successful and the second listbox was changed

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I don't know why case would make a difference, but if I change
the fireevent call to FireEvent, it works on XP sp2.
It also works if you generate the makepy wrappers (probably
because that forces case-sensitivity)

hth
Roger

<ca*****@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello,

I was wondering if anyone could tell me why fireEvent works in every
language but Python with the latest Internet Explorer?

I tried this page that has two listboxes if you select Listbox A the
Listbox B should change.

The code status:
Works fine with Python 2.3, 2.4 in Windows XPsp1
DOES not work Python 2.3, 2.4 XP Sp2 or the lastest IE
Works fine with "RUBY" on Win 2000, XP sp1 and XP sp2
Work fine with PERL on on Win 2000, XP sp1 and XP sp2

Luckily I know both Ruby, VB and Perl so I could prove there was a
problem.

Here is the example code in both Python and Ruby:

Python:
from win32com.client import DispatchEx
import time


def wait(ie):
while ie.Busy: time.sleep(0.1)

doc = ie.Document
while doc.ReadyState != 'complete': time.sleep(0.1)

ie = DispatchEx('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate( 'https://enroll.ou.edu/' )
wait(ie)
ie.Document.forms[0].campus.value='200'
ie.Document.forms[0].campus.fireevent('onchange')

Results:
Traceback (most recent call last):
File
"C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py" ,
line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\automation\poScript1.py", line 18, in ?
ie.Document.forms[0].campus.fireevent('onchange')
File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line
154, in __call__
return
self._get_good_object_(self._oleobj_.Invoke(*allAr gs),self._olerepr_.defaultDispatchName,None)
com_error: (-2147024891, 'Access is denied.', None, None)

Ruby:
# OU Registration & Enrollment Online
require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome
ie.navigate('https://enroll.ou.edu/')
while ie.busy
end

READYSTATE_COMPLETE = 4
until
ie.readyState == READYSTATE_COMPLETE
end
form = ie.document.forms(0)
form.campus.value = '200'
form.campus.fireevent('onchange')

Results: fireEvent was successful and the second listbox was changed



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 18 '05 #2

P: n/a
Roger,

Thank you so much! I have been pulling my hair out over this!

Rob.

Roger Upole wrote:
I don't know why case would make a difference, but if I change
the fireevent call to FireEvent, it works on XP sp2.
It also works if you generate the makepy wrappers (probably
because that forces case-sensitivity)

hth
Roger

<ca*****@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello,

I was wondering if anyone could tell me why fireEvent works in every language but Python with the latest Internet Explorer?

I tried this page that has two listboxes if you select Listbox A the Listbox B should change.

The code status:
Works fine with Python 2.3, 2.4 in Windows XPsp1
DOES not work Python 2.3, 2.4 XP Sp2 or the lastest IE
Works fine with "RUBY" on Win 2000, XP sp1 and XP sp2
Work fine with PERL on on Win 2000, XP sp1 and XP sp2

Luckily I know both Ruby, VB and Perl so I could prove there was a
problem.

Here is the example code in both Python and Ruby:

Python:
from win32com.client import DispatchEx
import time


def wait(ie):
while ie.Busy: time.sleep(0.1)

doc = ie.Document
while doc.ReadyState != 'complete': time.sleep(0.1)

ie = DispatchEx('InternetExplorer.Application')
ie.Visible = 1
ie.Navigate( 'https://enroll.ou.edu/' )
wait(ie)
ie.Document.forms[0].campus.value='200'
ie.Document.forms[0].campus.fireevent('onchange')

Results:
Traceback (most recent call last):
File
"C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\automation\poScript1.py", line 18, in ?
ie.Document.forms[0].campus.fireevent('onchange')
File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 154, in __call__
return
self._get_good_object_(self._oleobj_.Invoke(*allAr gs),self._olerepr_.defaultDispatchName,None) com_error: (-2147024891, 'Access is denied.', None, None)

Ruby:
# OU Registration & Enrollment Online
require 'win32ole'
ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.gohome
ie.navigate('https://enroll.ou.edu/')
while ie.busy
end

READYSTATE_COMPLETE = 4
until
ie.readyState == READYSTATE_COMPLETE
end
form = ie.document.forms(0)
form.campus.value = '200'
form.campus.fireevent('onchange')

Results: fireEvent was successful and the second listbox was changed

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet

News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World!
100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.