Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 23 additions & 35 deletions source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@ def getStartAfterLogon() -> bool:
has been registered to start after logon on Windows 7
or by earlier NVDA versions.
"""
if (
easeOfAccess.canConfigTerminateOnDesktopSwitch
and easeOfAccess.willAutoStart(easeOfAccess.AutoStartContext.AFTER_LOGON)
):
if easeOfAccess.willAutoStart(easeOfAccess.AutoStartContext.AFTER_LOGON):
return True
try:
k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RegistryKey.RUN.value)
Expand Down Expand Up @@ -348,43 +345,34 @@ def setStartAfterLogon(enable: bool) -> None:
"""Not to be confused with setStartOnLogonScreen.

Toggle if NVDA automatically starts after a logon.
Sets easeOfAccess related registry keys on Windows 8 or newer.

On Windows 7 this sets the registry run key.
Sets easeOfAccess related registry keys.

When toggling off, always delete the registry run key
in case it was set by an earlier version of NVDA or on Windows 7 or earlier.
in case it was set by an earlier version of NVDA.
"""
if getStartAfterLogon() == enable:
return
if easeOfAccess.canConfigTerminateOnDesktopSwitch:
easeOfAccess.setAutoStart(easeOfAccess.AutoStartContext.AFTER_LOGON, enable)
if enable:
return
# We're disabling, so ensure the run key is cleared,
# as it might have been set by an old version.
run = False
else:
run = enable
easeOfAccess.setAutoStart(easeOfAccess.AutoStartContext.AFTER_LOGON, enable)
if enable:
return
# We're disabling, so ensure the run key is cleared,
# as it might have been set by an old version.
k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RegistryKey.RUN.value, 0, winreg.KEY_WRITE)
if run:
winreg.SetValueEx(k, "nvda", None, winreg.REG_SZ, sys.argv[0])
else:
try:
winreg.QueryValue(k, "nvda")
except FileNotFoundError:
log.debug(
"The run registry key is not set for setStartAfterLogon."
"This is expected for Windows 8+ which uses ease of access"
)
return
try:
winreg.DeleteValue(k, "nvda")
except WindowsError:
log.error(
"Couldn't unset registry key for nvda to start after logon.",
exc_info=True
)
try:
winreg.QueryValue(k, "nvda")
except FileNotFoundError:
log.debug(
"The run registry key is not set for setStartAfterLogon."
"This is expected since ease of access is used"
)
return
try:
winreg.DeleteValue(k, "nvda")
except WindowsError:
log.error(
"Couldn't unset registry key for nvda to start after logon.",
exc_info=True
)


SLAVE_FILENAME = os.path.join(globalVars.appDir, "nvda_slave.exe")
Expand Down
6 changes: 3 additions & 3 deletions source/easeOfAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
import NVDAState
import winreg
import winUser
import winVersion


# Windows >= 8
canConfigTerminateOnDesktopSwitch: bool = winVersion.getWinVer() >= winVersion.WIN8
Comment thread
seanbudd marked this conversation as resolved.
Resolved
_APP_KEY_NAME = "nvda_nvda_v1"


Expand All @@ -32,6 +29,9 @@ def __getattr__(attrName: str) -> Any:
if attrName == "APP_KEY_NAME" and NVDAState._allowDeprecatedAPI():
log.warning("APP_KEY_NAME is deprecated.")
return _APP_KEY_NAME
if attrName == "canConfigTerminateOnDesktopSwitch" and NVDAState._allowDeprecatedAPI():
log.warning("canConfigTerminateOnDesktopSwitch is deprecated.")
return True
raise AttributeError(f"module {repr(__name__)} has no attribute {repr(attrName)}")


Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Code which imports from one of them, should instead import from the replacement
=== Deprecations ===

- Using ``watchdog.getFormattedStacksForAllThreads`` is deprecated - please use ``logHandler.getFormattedStacksForAllThreads`` instead. (#15616, @lukaszgo1)
- ``easeOfAccess.canConfigTerminateOnDesktopSwitch`` has been deprecated, as it became obsolete since Windows 7 is no longer supported. (#15644, @LeonarddeR)
-


Expand Down