示例#1
0
def getStartOnLogonScreen() -> bool:
	"""Not to be confused with getStartAfterLogon.

	Checks if NVDA is set to start on the logon screen.

	Checks related easeOfAccess local machine registry keys.
	Then, checks a NVDA registry key to see if NVDA
	has been registered to start on logon by earlier NVDA versions.
	"""
	if easeOfAccess.willAutoStart(easeOfAccess.AutoStartContext.ON_LOGON_SCREEN):
		return True
	try:
		k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, RegistryKey.NVDA.value)
	except FileNotFoundError:
		log.debugWarning(f"Could not find NVDA reg key {RegistryKey.NVDA}", exc_info=True)
	except WindowsError:
		log.error(f"Failed to open NVDA reg key {RegistryKey.NVDA}", exc_info=True)
	else:
		try:
			return bool(winreg.QueryValueEx(k, "startOnLogonScreen")[0])
		except FileNotFoundError:
			log.debug(f"Could not find startOnLogonScreen value for {RegistryKey.NVDA} - likely unset.")
			return False
		except WindowsError:
			log.error(f"Failed to query startOnLogonScreen value for {RegistryKey.NVDA}", exc_info=True)
			return False
	return False
示例#2
0
def getStartAfterLogon() -> bool:
	"""Not to be confused with getStartOnLogonScreen.

	Checks if NVDA is set to start after a logon.
	Checks related easeOfAccess current user registry keys on Windows 8 or newer.
	Then, checks the registry run key to see if NVDA
	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)
	):
		return True
	try:
		k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RegistryKey.RUN.value)
	except FileNotFoundError:
		log.debugWarning(
			f"Unable to find run registry key {RegistryKey.RUN}",
			exc_info=True
		)
		return False
	except WindowsError:
		log.error(
			f"Unable to open run registry key {RegistryKey.RUN}",
			exc_info=True
		)
		return False

	try:
		val = winreg.QueryValueEx(k, "nvda")[0]
	except FileNotFoundError:
		log.debug("NVDA is not set to start after logon")
		return False
	except WindowsError:
		log.error("Failed to query NVDA key to set start after logon", exc_info=True)
		return False

	try:
		startAfterLogonPath = os.stat(val)
	except WindowsError:
		log.error(
			"Failed to access the start after logon directory.",
			exc_info=True
		)
		return False
	
	try:
		currentSourcePath = os.stat(sys.argv[0])
	except FileNotFoundError:
		log.debug("Failed to access the current running NVDA directory.")
		return False
	except WindowsError:
		log.error(
			"Failed to access the current running NVDA directory.",
			exc_info=True
		)
		return False

	return currentSourcePath == startAfterLogonPath
示例#3
0
def getStartOnLogonScreen():
	if easeOfAccess.isSupported and easeOfAccess.willAutoStart(winreg.HKEY_LOCAL_MACHINE):
		return True
	try:
		k = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, NVDA_REGKEY)
		return bool(winreg.QueryValueEx(k, u"startOnLogonScreen")[0])
	except WindowsError:
		return False
示例#4
0
def getStartOnLogonScreen():
	if easeOfAccess.isSupported and easeOfAccess.willAutoStart(_winreg.HKEY_LOCAL_MACHINE):
		return True
	try:
		k = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, NVDA_REGKEY)
		return bool(_winreg.QueryValueEx(k, u"startOnLogonScreen")[0])
	except WindowsError:
		return False
示例#5
0
def getStartAfterLogon():
	if (easeOfAccess.isSupported and easeOfAccess.canConfigTerminateOnDesktopSwitch
			and easeOfAccess.willAutoStart(winreg.HKEY_CURRENT_USER)):
		return True
	try:
		k = winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_REGKEY)
		val = winreg.QueryValueEx(k, u"nvda")[0]
		return os.stat(val) == os.stat(sys.argv[0])
	except (WindowsError, OSError):
		return False
示例#6
0
def getStartAfterLogon():
	if (easeOfAccess.isSupported and easeOfAccess.canConfigTerminateOnDesktopSwitch
			and easeOfAccess.willAutoStart(_winreg.HKEY_CURRENT_USER)):
		return True
	try:
		k = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY)
		val = _winreg.QueryValueEx(k, u"nvda")[0]
		return os.stat(val) == os.stat(sys.argv[0])
	except (WindowsError, OSError):
		return False