Skip to content
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
Prev Previous commit
Next Next commit
fix imports
  • Loading branch information
seanbudd committed Aug 4, 2025
commit 306b3cd1116e8ca3f24df2b579e20bbc7b38a9cb
2 changes: 1 addition & 1 deletion source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class RegistryKey(str, Enum):
SERVICE_DEBUG_SUBKEY = "serviceDebug"


class _RegistryKeyX86(str, Enum):
class _RegistryKeyX86(str, Enum): # type: ignore[reportUnusedClass]
"""
Used to access the 32-bit registry view on x64 systems.
For cleaning up legacy 32-bit NVDA copies.
Expand Down
34 changes: 20 additions & 14 deletions source/easeOfAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from enum import Enum, IntEnum
from typing import Any

from config import RegistryKey as _RegistryKey
from logHandler import log
import NVDAState
import winreg
Expand All @@ -17,6 +16,8 @@

def __getattr__(attrName: str) -> Any:
"""Module level `__getattr__` used to preserve backward compatibility."""
from config import RegistryKey as _RegistryKey

if attrName == "RegistryKey" and NVDAState._allowDeprecatedAPI():
log.warning("easeOfAccess.RegistryKey is deprecated, use config.RegistryKey instead.")

Expand Down Expand Up @@ -50,10 +51,11 @@ class AutoStartContext(IntEnum):


def isRegistered() -> bool:
from config import RegistryKey
try:
winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE,
_RegistryKey.EASE_OF_ACCESS_APP.value,
RegistryKey.EASE_OF_ACCESS_APP.value,
0,
winreg.KEY_READ | winreg.KEY_WOW64_64KEY,
)
Expand All @@ -66,10 +68,11 @@ def isRegistered() -> bool:


def notify(signal):
from config import RegistryKey
if not isRegistered():
return
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, _RegistryKey.EASE_OF_ACCESS_TEMP.value) as rkey:
winreg.SetValueEx(rkey, _RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME, None, winreg.REG_DWORD, signal)
with winreg.CreateKey(winreg.HKEY_CURRENT_USER, RegistryKey.EASE_OF_ACCESS_TEMP.value) as rkey:
winreg.SetValueEx(rkey, RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME, None, winreg.REG_DWORD, signal)
keys = []
# The user might be holding unwanted modifiers.
for vk in winUser.VK_SHIFT, winUser.VK_CONTROL, winUser.VK_MENU:
Expand Down Expand Up @@ -102,7 +105,8 @@ def willAutoStart(autoStartContext: AutoStartContext) -> bool:

Returns False on failure
"""
return _RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME in _getAutoStartConfiguration(autoStartContext)
from config import RegistryKey
return RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME in _getAutoStartConfiguration(autoStartContext)


def _getAutoStartConfiguration(autoStartContext: AutoStartContext) -> list[str]:
Expand All @@ -112,30 +116,31 @@ def _getAutoStartConfiguration(autoStartContext: AutoStartContext) -> list[str]:

Returns an empty list on failure.
"""
from config import RegistryKey
try:
k = winreg.OpenKey(
autoStartContext.value,
_RegistryKey.EASE_OF_ACCESS.value,
RegistryKey.EASE_OF_ACCESS.value,
0,
winreg.KEY_READ | winreg.KEY_WOW64_64KEY,
)
except FileNotFoundError:
log.debug(f"Unable to find existing {autoStartContext} {_RegistryKey.EASE_OF_ACCESS}")
log.debug(f"Unable to find existing {autoStartContext} {RegistryKey.EASE_OF_ACCESS}")
return []
except WindowsError:
log.error(
f"Unable to open {autoStartContext} {_RegistryKey.EASE_OF_ACCESS} for reading",
f"Unable to open {autoStartContext} {RegistryKey.EASE_OF_ACCESS} for reading",
exc_info=True,
)
return []

try:
conf: list[str] = winreg.QueryValueEx(k, "Configuration")[0].split(",")
except FileNotFoundError:
log.debug(f"Unable to find {autoStartContext} {_RegistryKey.EASE_OF_ACCESS} configuration")
log.debug(f"Unable to find {autoStartContext} {RegistryKey.EASE_OF_ACCESS} configuration")
except WindowsError:
log.error(
f"Unable to query {autoStartContext} {_RegistryKey.EASE_OF_ACCESS} configuration",
f"Unable to query {autoStartContext} {RegistryKey.EASE_OF_ACCESS} configuration",
exc_info=True,
)
else:
Expand All @@ -156,21 +161,22 @@ def setAutoStart(autoStartContext: AutoStartContext, enable: bool) -> None:

Raises `Union[WindowsError, FileNotFoundError]`
"""
from config import RegistryKey
conf = _getAutoStartConfiguration(autoStartContext)
currentlyEnabled = _RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME in conf
currentlyEnabled = RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME in conf
changed = False

if enable and not currentlyEnabled:
conf.append(_RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME)
conf.append(RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME)
changed = True
elif not enable and currentlyEnabled:
conf.remove(_RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME)
conf.remove(RegistryKey.EASE_OF_ACCESS_APP_KEY_NAME)
changed = True

if changed:
k = winreg.OpenKey(
autoStartContext.value,
_RegistryKey.EASE_OF_ACCESS.value,
RegistryKey.EASE_OF_ACCESS.value,
0,
winreg.KEY_READ | winreg.KEY_WRITE | winreg.KEY_WOW64_64KEY,
)
Expand Down