App

external interface App : EventEmitter(source)

Properties

Link copied to clipboard

A boolean property that's true if Chrome's accessibility support is enabled, false otherwise. This property will be true if the use of assistive technologies, such as screen readers, has been detected. Setting this property to true manually enables Chrome's accessibility support, allowing developers to expose accessibility switch to users in application settings.

Link copied to clipboard
Link copied to clipboard
abstract var applicationMenu: Menu?

A Menu | null property that returns Menu if one has been set and null otherwise. Users can pass a Menu to set this property.

Link copied to clipboard
abstract var badgeCount: Double

An Integer property that returns the badge count for current app. Setting the count to 0 will hide the badge.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val commandLine: CommandLine

A CommandLine object that allows you to read and manipulate the command line arguments that Chromium uses.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val dock: Dock

A Dock | undefined object that allows you to perform actions on your app icon in the user's dock on macOS.

Link copied to clipboard
Link copied to clipboard
abstract val isPackaged: Boolean

A boolean property that returns true if the app is packaged, false otherwise. For many apps, this property can be used to distinguish development and production environments.

Link copied to clipboard
Link copied to clipboard
abstract var name: String

A string property that indicates the current application's name, which is the name in the application's package.json file.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

A boolean which when true indicates that the app is currently running under an ARM64 translator (like the macOS Rosetta Translator Environment or Windows WOW).

Link copied to clipboard
Link copied to clipboard

A string which is the user agent string Electron will use as a global fallback.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addListener(type: EventType, listener: EventListener)
Link copied to clipboard
abstract fun addRecentDocument(path: String)

Adds path to the recent documents list.

Link copied to clipboard
abstract fun clearRecentDocuments()

Clears the recent documents list.

Link copied to clipboard

Configures host resolution (DNS and DNS-over-HTTPS). By default, the following resolvers will be used, in order:

Link copied to clipboard

By default, Chromium disables 3D APIs (e.g. WebGL) until restart on a per domain basis if the GPU processes crashes too frequently. This function disables that behavior.

Link copied to clipboard

Disables hardware acceleration for current app.

Link copied to clipboard
fun emit(type: EventType, vararg args: Any?): Boolean
Link copied to clipboard
abstract fun enableSandbox()

Enables full sandbox mode on the app. This means that all renderers will be launched sandboxed, regardless of the value of the sandbox flag in WebPreferences.

Link copied to clipboard
Link copied to clipboard
abstract fun exit(exitCode: Double = definedExternally)

Exits immediately with exitCode. exitCode defaults to 0.

Link copied to clipboard
abstract fun focus(options: FocusOptions = definedExternally)

On Linux, focuses on the first visible window. On macOS, makes the application the active app. On Windows, focuses on the application's first window.

Link copied to clipboard

Resolve with an object containing the following:

Link copied to clipboard

Name of the application handling the protocol, or an empty string if there is no handler. For instance, if Electron is the default handler of the URL, this could be Electron on Windows and Mac. However, don't rely on the precise format which is not guaranteed to remain unchanged. Expect a different format on Linux, possibly with a .desktop suffix.

Link copied to clipboard

Array of ProcessMetric objects that correspond to memory and CPU usage statistics of all the processes associated with the app.

Link copied to clipboard
abstract fun getAppPath(): String

The current application directory.

Link copied to clipboard
abstract fun getBadgeCount(): Double

The current value displayed in the counter badge.

Link copied to clipboard

The type of the currently running activity.

Link copied to clipboard
abstract fun getFileIcon(path: String, options: FileIconOptions = definedExternally): Promise<NativeImage>

fulfilled with the app's icon, which is a NativeImage.

Link copied to clipboard

The Graphics Feature Status from chrome://gpu/.

Link copied to clipboard
abstract fun getGPUInfo(infoType: AppGetGPUInfoInfoType): Promise<Any?>

For infoType equal to complete: Promise is fulfilled with Object containing all the GPU Information as in chromium's GPUInfo object. This includes the version and driver information that's shown on chrome://gpu page.

Link copied to clipboard
Link copied to clipboard
abstract fun getLocale(): String

The current application locale, fetched using Chromium's l10n_util library. Possible return values are documented here.

Link copied to clipboard

User operating system's locale two-letter ISO 3166 country code. The value is taken from native OS APIs.

Link copied to clipboard
abstract fun getLoginItemSettings(options: LoginItemSettingsOptions = definedExternally): LoginItemSettings

If you provided path and args options to app.setLoginItemSettings, then you need to pass the same arguments here for openAtLogin to be set correctly.

Link copied to clipboard
Link copied to clipboard
abstract fun getName(): String

The current application's name, which is the name in the application's package.json file.

Link copied to clipboard
abstract fun getPath(name: AppGetPathName): String

A path to a special directory or file associated with name. On failure, an Error is thrown.

Link copied to clipboard

The user's preferred system languages from most preferred to least preferred, including the country codes if applicable. A user can modify and add to this list on Windows or macOS through the Language and Region settings.

Link copied to clipboard
abstract fun getSystemLocale(): String

The current system locale. On Windows and Linux, it is fetched using Chromium's i18n library. On macOS, [NSLocale currentLocale] is used instead. To get the user's current system language, which is not always the same as the locale, it is better to use app.getPreferredSystemLanguages().

Link copied to clipboard
abstract fun getVersion(): String

The version of the loaded application. If no version is found in the application's package.json file, the version of the current bundle or executable is returned.

Link copied to clipboard

This method returns whether or not this instance of your app is currently holding the single instance lock. You can request the lock with app.requestSingleInstanceLock() and release with app.releaseSingleInstanceLock()

Link copied to clipboard
abstract fun hide()

Hides all application windows without minimizing them.

Link copied to clipboard
abstract fun importCertificate(options: ImportCertificateOptions, callback: (result: Double) -> Unit)

Imports the certificate in pkcs12 format into the platform certificate store. callback is called with the result of import operation, a value of 0 indicates success while any other value indicates failure according to Chromium net_error_list.

Link copied to clipboard

Invalidates the current Handoff user activity.

Link copied to clipboard

true if Chrome's accessibility support is enabled, false otherwise. This API will return true if the use of assistive technologies, such as screen readers, has been detected. See https://www.chromium.org/developers/design-documents/accessibility for more details.

Link copied to clipboard
abstract fun isDefaultProtocolClient(protocol: String, path: String = definedExternally, args: ReadonlyArray<String> = definedExternally): Boolean

Whether the current executable is the default handler for a protocol (aka URI scheme).

Link copied to clipboard

whether or not the current OS version allows for native emoji pickers.

Link copied to clipboard
abstract fun isHidden(): Boolean

true if the application—including all of its windows—is hidden (e.g. with Command-H), false otherwise.

Link copied to clipboard

Whether the application is currently running from the systems Application folder. Use in combination with app.moveToApplicationsFolder()

Link copied to clipboard
abstract fun isReady(): Boolean

true if Electron has finished initializing, false otherwise. See also app.whenReady().

Link copied to clipboard

whether Secure Keyboard Entry is enabled.

Link copied to clipboard
abstract fun isUnityRunning(): Boolean

Whether the current desktop environment is Unity launcher.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun moveToApplicationsFolder(options: MoveToApplicationsFolderOptions = definedExternally): Boolean

Whether the move was successful. Please note that if the move is successful, your application will quit and relaunch.

Link copied to clipboard
fun off(type: EventType, listener: EventListener)
Link copied to clipboard
fun on(type: EventType, listener: EventListener)
Link copied to clipboard
fun once(type: EventType, listener: EventListener)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun quit()

Try to close all windows. The before-quit event will be emitted first. If all windows are successfully closed, the will-quit event will be emitted and by default the application will terminate.

Link copied to clipboard
Link copied to clipboard
abstract fun relaunch(options: RelaunchOptions = definedExternally)

Relaunches the app when current instance exits.

Link copied to clipboard

Releases all locks that were created by requestSingleInstanceLock. This will allow multiple instances of the application to once again run side by side.

Link copied to clipboard
Link copied to clipboard
abstract fun removeAsDefaultProtocolClient(protocol: String, path: String = definedExternally, args: ReadonlyArray<String> = definedExternally): Boolean

Whether the call succeeded.

Link copied to clipboard
fun removeListener(type: EventType, listener: EventListener)
Link copied to clipboard
abstract fun requestSingleInstanceLock(additionalData: ReadonlyRecord<Any, Any?> = definedExternally): Boolean

The return value of this method indicates whether or not this instance of your application successfully obtained the lock. If it failed to obtain the lock, you can assume that another instance of your application is already running with the lock and exit immediately.

Link copied to clipboard
abstract fun resignCurrentActivity()

Marks the current Handoff user activity as inactive without invalidating it.

Link copied to clipboard
abstract fun resolveProxy(url: String): Promise<String>

Resolves with the proxy information for url that will be used when attempting to make requests using Net in the utility process.

Link copied to clipboard

Set the about panel options. This will override the values defined in the app's .plist file on macOS. See the Apple docs for more details. On Linux, values must be set in order to be shown; there are no defaults.

Link copied to clipboard

Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings. See Chromium's accessibility docs for more details. Disabled by default.

Link copied to clipboard

Sets the activation policy for a given app.

Link copied to clipboard
abstract fun setAppLogsPath(path: String = definedExternally)

Sets or creates a directory your app's logs which can then be manipulated with app.getPath() or app.setPath(pathName, newPath).

Link copied to clipboard
abstract fun setAppUserModelId(id: String)

Changes the Application User Model ID to id.

Link copied to clipboard
abstract fun setAsDefaultProtocolClient(protocol: String, path: String = definedExternally, args: ReadonlyArray<String> = definedExternally): Boolean

Whether the call succeeded.

Link copied to clipboard
abstract fun setBadgeCount(count: Double = definedExternally): Boolean

Whether the call succeeded.

Link copied to clipboard

Sets or removes a custom Jump List for the application, and returns one of the following strings:

Link copied to clipboard
abstract fun setLoginItemSettings(settings: Settings)

Set the app's login item settings.

Link copied to clipboard
Link copied to clipboard
abstract fun setName(name: String)

Overrides the current application's name.

Link copied to clipboard
abstract fun setPath(name: String, path: String)

Overrides the path to a special directory or file associated with name. If the path specifies a directory that does not exist, an Error is thrown. In that case, the directory should be created with fs.mkdirSync or similar.

Link copied to clipboard
abstract fun setProxy(config: ProxyConfig)
Link copied to clipboard
abstract fun setSecureKeyboardEntryEnabled(enabled: Boolean)

Set the Secure Keyboard Entry is enabled in your application.

Link copied to clipboard
abstract fun setUserActivity(type: String, userInfo: Any?, webpageURL: String = definedExternally)

Creates an NSUserActivity and sets it as the current activity. The activity is eligible for Handoff to another device afterward.

Link copied to clipboard
abstract fun setUserTasks(tasks: ReadonlyArray<Task>): Boolean

Adds tasks to the Tasks category of the Jump List on Windows.

Link copied to clipboard
abstract fun show()

Shows application windows after they were hidden. Does not automatically focus them.

Link copied to clipboard
abstract fun showAboutPanel()

Show the app's about panel options. These options can be overridden with app.setAboutPanelOptions(options). This function runs asynchronously.

Link copied to clipboard
abstract fun showEmojiPanel()

Show the platform's native emoji picker.

Link copied to clipboard
abstract fun startAccessingSecurityScopedResource(bookmarkData: String): Function<*>

This function must be called once you have finished accessing the security scoped file. If you do not remember to stop accessing the bookmark, kernel resources will be leaked and your app will lose its ability to reach outside the sandbox completely, until your app is restarted.

Link copied to clipboard
abstract fun updateCurrentActivity(type: String, userInfo: Any?)

Updates the current activity if its type matches type, merging the entries from userInfo into its current userInfo dictionary.

Link copied to clipboard
abstract fun whenReady(): Promise<Void>

fulfilled when Electron is initialized. May be used as a convenient alternative to checking app.isReady() and subscribing to the ready event if the app is not ready yet.