systemUtils module

System related functions.

systemUtils.hasSyswow64Dir() bool

Returns True if the current system has separate system32 directories for 32-bit processes.

systemUtils.openUserConfigurationDirectory()

Opens directory containing config files for the current user

systemUtils.openDefaultConfigurationDirectory()

Opens the directory which would be used to store configuration by default. Used as a fallback when trying to explore user config from the start menu, and NVDA is not running.

systemUtils.hasUiAccess()
systemUtils.TOKEN_ORIGIN = 17

Value from the TOKEN_INFORMATION_CLASS enumeration: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-token_information_class When calling The Win32 GetTokenInformation function, the buffer receives a TOKEN_ORIGIN value. If the token resulted from a logon that used explicit credentials, such as passing a name, domain, and password to the LogonUser function, then the TOKEN_ORIGIN structure will contain the ID of the logon session that created it. If the token resulted from network authentication, then this value will be zero.

class systemUtils.TokenOrigin

Bases: Structure

TOKEN_ORIGIN structure: https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-token_origin This structure is used in calls to the Win32 GetTokenInformation function.

_fields_ = [('originatingLogonSession', <class 'ctypes.c_ulonglong'>)]
originatingLogonSession

Structure/Union member

systemUtils.getProcessLogonSessionId(processHandle: int) int

Retrieves the ID of the logon session that created the process that the given processHandle belongs to. The function calls several Win32 functions: * OpenProcessToken: opens the access token associated with a process. * GetTokenInformation: retrieves a specified type of information about an access token.

The calling process must have appropriate access rights to obtain the information. GetTokenInformation is called with the TokenOrigin Value from the TOKEN_INFORMATION_CLASS enumeration. The resulting structure contains the session ID of the logon session that will be returned.

  • CloseHandle: To close the token handle.

systemUtils.getCurrentProcessLogonSessionId() int
systemUtils.execElevated(path, params=None, wait=False, handleAlreadyElevated=False)
systemUtils._getDesktopName() str
systemUtils._displayTextFileWorkaround(file: str) None
systemUtils._isSystemClockSecondsVisible() bool

Query the value of ‘ShowSecondsInSystemClock’ DWORD32 value in the Windows registry under the path HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionExplorerAdvanced. If the value is 1, return True, if the value is 0 or the key does not exist, return False.

@return: True if the ‘ShowSecondsInSystemClock’ value is 1, False otherwise.

class systemUtils.ExecAndPump(func: Callable[[...], _execAndPumpResT], *args, **kwargs)

Bases: Thread, Generic[_execAndPumpResT]

Executes the given function with given args and kwargs in a background thread, while blocking and pumping in the current thread.

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.

args is a list or tuple of arguments for the target invocation. Defaults to ().

kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.

run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.