Repository: nvaccess/nvda

Issue:
Windows 11 Notepad: status bar is not announced
Hi,

While a bug report would be a better category, this is marked as a feature request due to the background information provided below.

### Background
As part of modernizing inbox apps (programs shipping with Windows by default), Notepad was updated on Windows 11 to adopt the new UI changes. In a recent blog post, Microsoft highlighted changes introduced in Notepad.

The new Notepad was introduced to everyone in February 2022. This version (11.2112) did introduce redesigned UI elements and use of rich edit control for document content. However, it had issues, notably screen readers such as NVDA repeating content from the line above when there was a line of text followed by a blank line, then end of the document. This, together with text repetition problem when Enter key is pressed, was resolved in Notepad 11.2203 released in late April.

One issue is not resolved: status bar reading. In Windows 10 Notepad, one can perform status bar command (NVDA+End in desktop layout, NVDA+Shift+End in laptop layout) and status bar text will be announced if enabled from View menu. This is not the case in Windows 11.

### Is your feature request related to a problem? Please describe.
Due to UI redesign, NVDA cannot obtain status bar information in Windows 11 Notepad. Further, status bar is located on different UIA tree location (fifth child of the foreground window in 11.2112, eighth child in 11.2203).

### Describe the solution you'd like
Implement status bar retrieval method in the new Notepad app module. Due to the fact that newer Notepad includes bug fixes and is generally available to everyone, tree traversal route will folow that of 11.2203 (that is, minimum supported version will be 11.2203 released in April 2022).

### Describe alternatives you've considered
Two alternatives:

1. Leave things as is. This is because Notepad app module is the example app module used in dev docs. Introducing a new Notepad module will require looking for a new simple app to provide examples for developers getting started with app modules. Alternatively, continue using Notepad with a note that for folks using Windows 11, a different app should be used to test app module basics.
2. Improve api.getStatusBar function to take situations like Windows 11 Notepad into account when fetching status bars.

### Additional context
A working example is included in Windows App Essentials add-on which will be the basis of a follow-up pull request.

Thanks.


Discussion:
Hi,

IMPORTANT: this is separate from a request in #13506 asking Notepad menu to be navigable via mouse and/or touch as that request has to do with UI elements, not status bar content.

Thanks.

Resolving patch:
diff --git a/source/appModules/notepad.py b/source/appModules/notepad.py
new file mode 100644
--- /dev/null
+++ b/source/appModules/notepad.py
@@ -0,0 +1,42 @@
+# A part of NonVisual Desktop Access (NVDA)
+# Copyright (C) 2022 NV Access Limited, Joseph Lee
+# This file is covered by the GNU General Public License.
+# See the file COPYING for more details.
+
+"""App module for Windows Notepad.
+While this app module also covers older Notepad releases,
+this module provides workarounds for Windows 11 Notepad."""
+
+import appModuleHandler
+import api
+
+
+class AppModule(appModuleHandler.AppModule):
+
+	def _get_statusBar(self):
+		"""Retrieves Windows 11 Notepad status bar.
+		In Windows 10 and earlier, status bar can be obtained by looking at the bottom of the screen.
+		Windows 11 Notepad uses Windows 11 UI design (top-level window is labeled "DesktopWindowXamlSource",
+		therefore status bar cannot be obtained by position alone.
+		If visible, a child of the foreground window hosts the status bar elements.
+		Status bar child position must be checked whenever Notepad is updated on stable Windows 11 releases
+		as Notepad is updated through Microsoft Store as opposed to tied to specific Windows releases.
+		L{api.getStatusBar} will resort to position lookup if C{NotImplementedError} is raised.
+		"""
+		# #13688: Notepad 11 uses Windows 11 user interface, therefore status bar is harder to obtain.
+		# This does not affect earlier versions.
+		notepadVersion = int(self.productVersion.split(".")[0])
+		if notepadVersion < 11:
+			raise NotImplementedError()
+		# And no, status bar is shown when editing documents.
+		# Thankfully, of all the UIA objects encountered, document window has a unique window class name.
+		if api.getFocusObject().windowClassName != "RichEditD2DPT":
+			raise NotImplementedError()
+		# Look for a specific child as some children report the same UIA properties such as class name.
+		# Make sure to look for a foreground UIA element which hosts status bar content if visible.
+		notepadStatusBarIndex = 7
+		statusBar = api.getForegroundObject().children[notepadStatusBarIndex].firstChild
+		# No location for a disabled status bar i.e. location is 0 (x, y, width, height).
+		if not any(statusBar.location):
+			raise NotImplementedError()
+		return statusBar


Test patch: