11# A part of NonVisual Desktop Access (NVDA)
2- # Copyright (C) 2022 NV Access Limited, Joseph Lee
2+ # Copyright (C) 2022-2023 NV Access Limited, Joseph Lee
33# This file is covered by the GNU General Public License.
44# See the file COPYING for more details.
55
99
1010import appModuleHandler
1111import api
12+ import UIAHandler
13+ from NVDAObjects .UIA import UIA
14+ from NVDAObjects import NVDAObject
1215
1316
1417class AppModule (appModuleHandler .AppModule ):
1518
16- def _get_statusBar (self ):
19+ def _get_statusBar (self ) -> NVDAObject :
1720 """Retrieves Windows 11 Notepad status bar.
1821 In Windows 10 and earlier, status bar can be obtained by looking at the bottom of the screen.
1922 Windows 11 Notepad uses Windows 11 UI design (top-level window is labeled "DesktopWindowXamlSource",
@@ -32,10 +35,23 @@ def _get_statusBar(self):
3235 # Thankfully, of all the UIA objects encountered, document window has a unique window class name.
3336 if api .getFocusObject ().windowClassName != "RichEditD2DPT" :
3437 raise NotImplementedError ()
35- # Look for a specific child as some children report the same UIA properties such as class name.
36- # Make sure to look for a foreground UIA element which hosts status bar content if visible.
37- notepadStatusBarIndex = 7
38- statusBar = api .getForegroundObject ().children [notepadStatusBarIndex ].firstChild
38+ # Obtain status bar text across Notepad 11 releases.
39+ clientObject = UIAHandler .handler .clientObject
40+ condition = clientObject .CreatePropertyCondition (UIAHandler .UIA_AutomationIdPropertyId , "ContentTextBlock" )
41+ uiItemWindow = clientObject .ElementFromHandleBuildCache (
42+ api .getForegroundObject ().windowHandle , UIAHandler .handler .baseCacheRequest
43+ )
44+ # Instantiate UIA object directly.
45+ # In order for this to work, a valid UIA pointer must be returned.
46+ try :
47+ statusBarText = UIA (
48+ UIAElement = uiItemWindow .FindFirstBuildCache (
49+ UIAHandler .TreeScope_Descendants , condition , UIAHandler .handler .baseCacheRequest
50+ )
51+ )
52+ except ValueError :
53+ raise NotImplementedError ()
54+ statusBar = statusBarText .parent
3955 # No location for a disabled status bar i.e. location is 0 (x, y, width, height).
4056 if not any (statusBar .location ):
4157 raise NotImplementedError ()
0 commit comments