illinois-dres-aitg / pyia2

Python interface to MSAA and IAccessible2 Interfaces
GNU General Public License v3.0
8 stars 10 forks source link

Add support for Python 3 #4

Closed drmfinlay closed 4 years ago

drmfinlay commented 4 years ago

I have gotten pyia2 working with Python 3, while still keeping it working with Python 2.7. I've added the six package as a dependency in setup.py.

CC @wolfmanstout

Testing

I have tested my changes mostly by using Dragonfly's integration with pyia2 (see this blog post). The IAccessible2-enabled application I tested with was Mozilla Firefox. pyia2's test scripts also work correctly using either major Python version.

PumpEvents() errors

One other thing I've done is suppressed Windows error messages raised from the PumpEvents comtypes function. For example:

[WinError -2147417835] OLE has sent a request and is waiting for a reply

These errors are only present on Python 3.x and seem to have no impact on pyia2's functionality. I've logged them as debug messages because they're pretty spammy.

64-bit trouble?

I noticed in my testing that the accessibility integration doesn't work on 64-bit versions of Python, or at least it doesn't work with Firefox. I'm guessing this is something to do with comtypes, the IAccessible2Proxy DLL or Dragonfly's pyia2 integration.

LexiconCode commented 4 years ago

64-bit trouble?

I noticed in my testing that the accessibility integration doesn't work on 64-bit versions of Python, or at least it doesn't work with Firefox. I'm guessing this is something to do with comtypes, the IAccessible2Proxy DLL or Dragonfly's pyia2 integration.

I think it's because you need a compiled 64-bit Dll? Can be obtained here

wolfmanstout commented 4 years ago

Thanks Dane! Hopefully the 64-bit DLL fixes the issue. That is already necessary for Chrome.

drmfinlay commented 4 years ago

@LexiconCode You might be right about that. Unfortunately, I'm unable to test it because I can't get the 64-bit DLL in that project to load.

It is still working in 64-bit Python on some level because these debug messages appear when focusing Firefox's address bar:

comtypes (DEBUG): Release [application | Mozilla Firefox]
comtypes (DEBUG): Release [editable text | Search with Google or enter address]
comtypes (DEBUG): Release <POINTER(IServiceProvider) ptr=0x287ead0 at ed79948>
comtypes (DEBUG): Release [editable text | Search with Google or enter address]

Similar messages appear when other windows are focused.

Anyway, the 64-bit issue could be worked out in another issue/PR. My main concern was making pyia2 work with Python 3 :)