Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

GetActiveObject fails when running with uiAccess #2483

Closed
nvaccessAuto opened this Issue Jun 22, 2012 · 13 comments

Comments

Projects
None yet
1 participant

Reported by peter on 2012-06-22 13:18
Hi developers,
I am trying to write a support script for lambda math editor (http://www.veia.it)
The currently opened document in the editor can be accessed through com object and here is my problem (may be that this is a python bug, not nvda bug).
from comtypes.client import GetActiveObject
a=GetActiveObject("Lambda.LambdaObj")
and here the error:
Traceback (most recent call last):
File "", line 1, in
File "comtypes\client__init__.pyo", line 180, in GetActiveObject
File "comtypes__init__.pyo", line 1165, in GetActiveObject
File "_ctypes/callproc.c", line 936, in GetResult
WindowsError: -2147221021 Operation unavailable

I tryed this on nvda python console and it seems that the problem is somewhere in python, because everything perfectly works in other languages. i tryed this in autohotkey:
asdf := ComObjactivate("lambda.lambdaobj")
a:=asdf.getline(2425818,-1,-1)
msgbox %a%
and everything worked which means that comobj instance of running lambda is in the table and is accessible for other applications.
Do you have any idea?
Thank you!
Blocking #2568

Comment 1 by mdcurran on 2012-06-24 23:39
Please test to see if this works when running from a portable copy of NVDA. If so, then the bug is known to us. The issue is that when installed (on Vista/7/8) we run with the UIAccess privilage (allowing NVDA to access the UI of apps running as administrator), but there seems to be a bug in Windows (specifically the running object table I think) that does not allow access to lower privilage COM objects from a higher level process.
We have not yet worked out a way around this, but it is something we would like to fix.

Comment 2 by peter on 2012-06-27 08:21
Hello,
The problem is still here with the portable version, but there are some differences.
The original code (from my first post in this ticket) does not work with the following error:

from comtypes import GetActiveObject

a=GetActiveObject("Lambda.LambdaObj")

Traceback (most recent call last):
File "", line 1, in
File "comtypes__init__.pyo", line 1165, in GetActiveObject
TypeError: byref() argument must be a ctypes instance, not 'str'

This is a new error, which i receive only in portable version of nvda.
I tryed to send a parameter to GetActiveObject as an ctypes buffer:

from comtypes import GetActiveObject

from ctypes import create_string_buffer

s=create_string_buffer('Lambda.LambdaObj',20)

a=GetActiveObject(s)

Traceback (most recent call last):
File "", line 1, in
File "comtypes__init__.pyo", line 1165, in GetActiveObject
File "_ctypes/callproc.c", line 936, in GetResult
WindowsError: -2147221021 Operation unavailable

So the same error as in installed version.
Peter

Comment 3 by peter on 2012-06-27 10:07
Well i am actually sure, that problem is somewhere in nvda's python. I installed portable python 2.7.3 and latest comtypes package for python 2.x and everything works perfectly. Can I somehow help? More debugging or what.
Thanks
Peter

Comment 4 by mdcurran on 2012-06-27 19:59
If you want to pass a progID to GetActiveObject, you need to use comtypes.client.GetActiveObject, not comtypes.GetActiveObject. The latter only takes a cslID, hense the type error.

Comment 5 by peter on 2012-06-28 07:22
Oops sorry, my stupid mistake. It perfectly works with portable version of nvda.

Comment 6 by jteh on 2013-01-09 01:19
Changes:
Changed title from "com objects in app module" to "GetActiveObject fails when running with uiAccess"

Comment by jteh on 2013-01-09 01:20
(In #2568) We need a solution to #2483 before we can consider this for inclusion.

Comment 8 by jteh on 2013-01-09 02:56
I'm experimenting with a way to do this in this branch: http://bzr.nvaccess.org/nvda/getActiveObjectUIAccess

Comment 9 by jteh on 2013-03-01 03:21
Mick, what do you think about merging this into 2013.1? It isn't widely tested, but it seems to work for me.

Comment 10 by mdcurran on 2013-03-05 00:16
Sounds fine to me.

Comment 11 by jteh on 2013-03-08 06:25
Merged in 4d91e2b.
Changes:
Milestone changed from None to 2013.1
State: closed

Comment 12 by travisroth on 2013-08-19 16:44
I was testing this with NVDA Master 9370 and trying to get an object from Office 2010. comtypes.client.GetActiveObject() is still failing for me when trying to get a "word.application" or "outlook.application". (Same error as above.) I know that Microsoft has done some security stuff with Outlook, but I wasn't expecting an issue with Word? Is this an Office issue or NVDA? Thanks.

Comment 13 by jteh on 2013-08-19 23:24
If you're running with uiAccess, you have to use comHelper.getActiveObject, not comtypes.client.GetActiveObject directly. This is documented both in the changeset and in the "Changes for Developers" section of the What's New document.

@nvaccessAuto nvaccessAuto added the bug label Nov 10, 2015

@nvaccessAuto nvaccessAuto added this to the 2013.1 milestone Nov 10, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment