Navigation Menu

Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetActiveObject fails when running with uiAccess #2483

Closed
nvaccessAuto opened this issue Jun 22, 2012 · 16 comments
Closed

GetActiveObject fails when running with uiAccess #2483

nvaccessAuto opened this issue Jun 22, 2012 · 16 comments
Labels
Milestone

Comments

@nvaccessAuto
Copy link

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

@nvaccessAuto
Copy link
Author

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.

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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.

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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"

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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.

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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

@nvaccessAuto
Copy link
Author

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.

@nvaccessAuto
Copy link
Author

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.

@Kerneels
Copy link

Kerneels commented Oct 6, 2017

Hi. I'm still getting this issue on 2017.3 NVDA version when trying to use OLE, log follows:

ERROR - RPC process 17360 (nvda_slave.exe) (08:22:56.081):
main.main:
slave error
Traceback (most recent call last):
File "nvda_slave.pyw", line 90, in main
File "comHelper.pyo", line 22, in lresultFromGetActiveObject
File "comtypes\client_init
.pyo", line 180, in GetActiveObject
File "comtypes_init_.pyo", line 1165, in GetActiveObject
File "_ctypes/callproc.c", line 950, in GetResult
WindowsError: [Error -2147221021] Operation unavailable
ERROR - appModuleHandler.fetchAppModule (08:22:56.094):
error in appModule 'gvim'
Traceback (most recent call last):
File "appModuleHandler.pyo", line 168, in fetchAppModule
File "C:\Users\Kerneels\AppData\Roaming\nvda\appModules\gvim.py", line 175, in init
File "comHelper.pyo", line 58, in getActiveObject
RuntimeError: Helper process unable to get object; see log for details

@Kerneels
Copy link

Kerneels commented Oct 6, 2017

OK. I'm now getting the OLE object if NVDA is run as administrator. So it works.

@derekriemer
Copy link
Collaborator

Should this ticket be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants