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

UI Automation in Windows Console: only enable UIA when available #9650

Merged
merged 5 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/NVDAObjects/IAccessible/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ def findOverlayClasses(self,clsList):
elif windowClassName.startswith("Chrome_"):
from . import chromium
chromium.findExtraOverlayClasses(self, clsList)
elif windowClassName == "ConsoleWindowClass":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than placing the code directly here, you can just place an entry in the _staticMap directory in this file. But as well as the window class, also check for an MSAA role of ROLE_SYSTEM_CLIENT. This will ensure that the subclass is only used for the actual client of the window, and not the system menu or scrollbars etc.
Something like:

("ConsoleWindowClass",oleacc.ROLE_SYSTEM_CLIENT):"winConsoleLegacy.WinConsoleLegacy",

from .winConsoleLegacy import winConsoleLegacy
clsList.append(winConsoleLegacy)


#Support for Windowless richEdit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#NVDAObjects/WinConsole.py
#NVDAObjects/IAccessible/winConsoleLegacy.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2007-2012 NV Access Limited
#Copyright (C) 2007-2019 NV Access Limited, Bill Dengler

import winConsoleHandler
from . import Window
import winConsoleHandlerLegacy as winConsoleHandler
from . import IAccessible
from ..behaviors import Terminal, EditableTextWithoutAutoSelectDetection
import api
import core

class WinConsole(Terminal, EditableTextWithoutAutoSelectDetection, Window):
class winConsoleLegacy(Terminal, EditableTextWithoutAutoSelectDetection, IAccessible):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a class, please use a capital W, I.e. WinConsoleLegacy.

STABILIZE_DELAY = 0.03

def _get_TextInfo(self):
consoleObject=winConsoleHandler.consoleObject
if consoleObject and self.windowHandle == consoleObject.windowHandle:
return winConsoleHandler.WinConsoleTextInfo
return super(WinConsole,self).TextInfo
return winConsoleHandler.legacyConsoleTextInfo
return super(winConsoleLegacy,self).TextInfo

def event_becomeNavigatorObject(self, isFocus=False):
if winConsoleHandler.consoleObject is not self:
Expand All @@ -28,17 +28,17 @@ def event_becomeNavigatorObject(self, isFocus=False):
# The user is returning to the focus object with object navigation.
# The focused console should always be monitored if possible.
self.startMonitoring()
super(WinConsole,self).event_becomeNavigatorObject(isFocus=isFocus)
super(winConsoleLegacy,self).event_becomeNavigatorObject(isFocus=isFocus)

def event_gainFocus(self):
if winConsoleHandler.consoleObject is not self:
if winConsoleHandler.consoleObject:
winConsoleHandler.disconnectConsole()
winConsoleHandler.connectConsole(self)
super(WinConsole, self).event_gainFocus()
super(winConsoleLegacy, self).event_gainFocus()

def event_loseFocus(self):
super(WinConsole, self).event_loseFocus()
super(winConsoleLegacy, self).event_loseFocus()
if winConsoleHandler.consoleObject is self:
winConsoleHandler.disconnectConsole()

Expand All @@ -49,7 +49,7 @@ def _getTextLines(self):
return winConsoleHandler.getConsoleVisibleLines()

def script_caret_backspaceCharacter(self, gesture):
super(WinConsole, self).script_caret_backspaceCharacter(gesture)
super(winConsoleLegacy, self).script_caret_backspaceCharacter(gesture)
# #2586: We use console update events for typed characters,
# so the typedCharacter event is never fired for the backspace key.
# Call it here so that speak typed words works as expected.
Expand Down
4 changes: 1 addition & 3 deletions source/NVDAObjects/window/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#NVDAObjects/window.py
#A part of NonVisual Desktop Access (NVDA)
#Copyright (C) 2006-2019 NV Access Limited, Babbage B.V.
#Copyright (C) 2006-2019 NV Access Limited, Babbage B.V., Bill Dengler
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.

Expand Down Expand Up @@ -124,8 +124,6 @@ def findOverlayClasses(self,clsList):
from .scintilla import Scintilla as newCls
elif windowClassName in ("AkelEditW", "AkelEditA"):
from .akelEdit import AkelEdit as newCls
elif windowClassName=="ConsoleWindowClass" and config.conf['UIA']['winConsoleImplementation'] != "UIA":
from .winConsole import WinConsole as newCls
elif windowClassName=="EXCEL7":
from .excel import Excel7Window as newCls
if newCls:
Expand Down
8 changes: 4 additions & 4 deletions source/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ def handlePowerStatusChange(self):
log.warning("Java Access Bridge not available")
except:
log.error("Error initializing Java Access Bridge support", exc_info=True)
import winConsoleHandler
log.debug("Initializing winConsole support")
winConsoleHandler.initialize()
import winConsoleHandlerLegacy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you rename this as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid confusion (in anticipation of UIA becoming the default).

log.debug("Initializing legacy winConsole support")
winConsoleHandlerLegacy.initialize()
import UIAHandler
log.debug("Initializing UIA support")
try:
Expand Down Expand Up @@ -542,7 +542,7 @@ def run(self):
_terminate(treeInterceptorHandler)
_terminate(IAccessibleHandler, name="IAccessible support")
_terminate(UIAHandler, name="UIA support")
_terminate(winConsoleHandler, name="winConsole support")
_terminate(winConsoleHandlerLegacy, name="Legacy winConsole support")
_terminate(JABHandler, name="Java Access Bridge support")
_terminate(appModuleHandler, name="app module handler")
_terminate(NVDAHelper)
Expand Down
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ def __init__(self, parent):

# Translators: This is the label for a checkbox in the
# Advanced settings panel.
label = _("Force UI Automation in the Windows Console")
label = _("Use UI Automation to access the Windows Console when available")
consoleUIADevMap = True if config.conf['UIA']['winConsoleImplementation'] == 'UIA' else False
self.ConsoleUIACheckBox=UIAGroup.addItem(wx.CheckBox(self, label=label))
self.ConsoleUIACheckBox.SetValue(consoleUIADevMap)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#winConsoleHandler.py
#winConsoleHandlerLegacy.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2009-2018 NV Access Limited, Babbage B.V.
#Copyright (C) 2009-2019 NV Access Limited, Babbage B.V., Bill Dengler

import gui
import winUser
import winKernel
import wincon
import winconLegacy as wincon
from colors import RGB
import eventHandler
from logHandler import log
Expand Down Expand Up @@ -150,7 +150,7 @@ def terminate():
if consoleObject:
disconnectConsole()

class WinConsoleTextInfo(textInfos.offsets.OffsetsTextInfo):
class legacyConsoleTextInfo(textInfos.offsets.OffsetsTextInfo):

_cache_consoleScreenBufferInfo=True
def _get_consoleScreenBufferInfo(self):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ This includes in Microsoft Word itself, and also the Microsoft Outlook message v
However, There may be some information which is either not exposed, or exposed incorrectly in some versions of Microsoft Office, which means this UI automation support cannot always be relied upon.
We still do not recommend that the majority of users turn this on by default, though we do welcome users of Office 2016/365 to test this feature and provide feedback.

==== Force UI Automation in the Windows Console====[AdvancedSettingsConsoleUIA]
==== Use UI Automation to access the Windows Console when available ====[AdvancedSettingsConsoleUIA]
When this option is enabled, NVDA will use a new, work in progress version of its support for Windows Console which takes advantage of [accessibility improvements made by Microsoft https://devblogs.microsoft.com/commandline/whats-new-in-windows-console-in-windows-10-fall-creators-update/]. This feature is highly experimental and is still incomplete, so its use is not yet recommended. However, once completed, it is anticipated that this new support will become the default, improving NVDA's performance and stability in Windows command consoles.

==== Automatically set system focus to focusable elements in Browse Mode ====[BrowseModeSettingsAutoFocusFocusableElements]
Expand Down