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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • calfdog@yahoo.com

    #1

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

    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('Int ernetExplorer.A pplication')
    ie.Visible = 1
    ie.Navigate( 'https://enroll.ou.edu/' )
    wait(ie)
    ie.Document.for ms[0].campus.value=' 200'
    ie.Document.for ms[0].campus.fireeve nt('onchange')

    Results:
    Traceback (most recent call last):
    File
    "C:\Python23\li b\site-packages\Python win\pywin\frame work\scriptutil s.py",
    line 310, in RunScript
    exec codeObject in __main__.__dict __
    File "C:\automation\ poScript1.py", line 18, in ?
    ie.Document.for ms[0].campus.fireeve nt('onchange')
    File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py", line
    154, in __call__
    return
    self._get_good_ object_(self._o leobj_.Invoke(* allArgs),self._ olerepr_.defaul tDispatchName,N one)
    com_error: (-2147024891, 'Access is denied.', None, None)





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

    READYSTATE_COMP LETE = 4
    until
    ie.readyState == READYSTATE_COMP LETE
    end
    form = ie.document.for ms(0)
    form.campus.val ue = '200'
    form.campus.fir eevent('onchang e')

    Results: fireEvent was successful and the second listbox was changed

  • Roger Upole

    #2
    Re: Win 32 - VB, Ruby, Perl VS Python with fireEvent

    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

    <calfdog@yahoo. com> wrote in message
    news:1111628957 .852581.307520@ g14g2000cwa.goo glegroups.com.. .[color=blue]
    > 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('Int ernetExplorer.A pplication')
    > ie.Visible = 1
    > ie.Navigate( 'https://enroll.ou.edu/' )
    > wait(ie)
    > ie.Document.for ms[0].campus.value=' 200'
    > ie.Document.for ms[0].campus.fireeve nt('onchange')
    >
    > Results:
    > Traceback (most recent call last):
    > File
    > "C:\Python23\li b\site-packages\Python win\pywin\frame work\scriptutil s.py",
    > line 310, in RunScript
    > exec codeObject in __main__.__dict __
    > File "C:\automation\ poScript1.py", line 18, in ?
    > ie.Document.for ms[0].campus.fireeve nt('onchange')
    > File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py", line
    > 154, in __call__
    > return
    > self._get_good_ object_(self._o leobj_.Invoke(* allArgs),self._ olerepr_.defaul tDispatchName,N one)
    > com_error: (-2147024891, 'Access is denied.', None, None)
    >
    >
    >
    >
    >
    > Ruby:
    > # OU Registration & Enrollment Online
    > require 'win32ole'
    > ie = WIN32OLE.new('I nternetExplorer .Application')
    > ie.visible = true
    > ie.gohome
    > ie.navigate('ht tps://enroll.ou.edu/')
    > while ie.busy
    > end
    >
    > READYSTATE_COMP LETE = 4
    > until
    > ie.readyState == READYSTATE_COMP LETE
    > end
    > form = ie.document.for ms(0)
    > form.campus.val ue = '200'
    > form.campus.fir eevent('onchang e')
    >
    > Results: fireEvent was successful and the second listbox was changed
    >[/color]




    ----== 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 =---

    Comment

    • calfdog@yahoo.com

      #3
      Re: Win 32 - VB, Ruby, Perl VS Python with fireEvent

      Roger,

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

      Rob.



      Roger Upole wrote:[color=blue]
      > 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
      >
      > <calfdog@yahoo. com> wrote in message
      > news:1111628957 .852581.307520@ g14g2000cwa.goo glegroups.com.. .[color=green]
      > > Hello,
      > >
      > > I was wondering if anyone could tell me why fireEvent works in[/color][/color]
      every[color=blue][color=green]
      > > language but Python with the latest Internet Explorer?
      > >
      > > I tried this page that has two listboxes if you select Listbox A[/color][/color]
      the[color=blue][color=green]
      > > 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('Int ernetExplorer.A pplication')
      > > ie.Visible = 1
      > > ie.Navigate( 'https://enroll.ou.edu/' )
      > > wait(ie)
      > > ie.Document.for ms[0].campus.value=' 200'
      > > ie.Document.for ms[0].campus.fireeve nt('onchange')
      > >
      > > Results:
      > > Traceback (most recent call last):
      > > File
      > >[/color][/color]
      "C:\Python23\li b\site-packages\Python win\pywin\frame work\scriptutil s.py",[color=blue][color=green]
      > > line 310, in RunScript
      > > exec codeObject in __main__.__dict __
      > > File "C:\automation\ poScript1.py", line 18, in ?
      > > ie.Document.for ms[0].campus.fireeve nt('onchange')
      > > File "C:\Python23\li b\site-packages\win32c om\client\dynam ic.py",[/color][/color]
      line[color=blue][color=green]
      > > 154, in __call__
      > > return
      > >[/color][/color]
      self._get_good_ object_(self._o leobj_.Invoke(* allArgs),self._ olerepr_.defaul tDispatchName,N one)[color=blue][color=green]
      > > com_error: (-2147024891, 'Access is denied.', None, None)
      > >
      > >
      > >
      > >
      > >
      > > Ruby:
      > > # OU Registration & Enrollment Online
      > > require 'win32ole'
      > > ie = WIN32OLE.new('I nternetExplorer .Application')
      > > ie.visible = true
      > > ie.gohome
      > > ie.navigate('ht tps://enroll.ou.edu/')
      > > while ie.busy
      > > end
      > >
      > > READYSTATE_COMP LETE = 4
      > > until
      > > ie.readyState == READYSTATE_COMP LETE
      > > end
      > > form = ie.document.for ms(0)
      > > form.campus.val ue = '200'
      > > form.campus.fir eevent('onchang e')
      > >
      > > Results: fireEvent was successful and the second listbox was[/color][/color]
      changed[color=blue][color=green]
      > >[/color]
      >
      >
      >
      >
      > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet[/color]
      News==----[color=blue]
      > http://www.newsfeeds.com The #1 Newsgroup Service in the World!
      >100,000 Newsgroups
      > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---[/color]

      Comment

      Working...