Neutralino.os
Neutralino.os
namespace contains methods related to the user's operating system.
#
os.execCommand(command, options)Executes a command and returns the output.
#
Parameterscommand
String: The command that is to be executed.
#
Optionsbackground
Boolean: Executes the command in background and resolve the Promise immediately if this is set totrue
. This option makes the process detached from the API function call, so if you need to connect with the newly created process later, consider usingos.spawnProcess
.stdIn
String: Standard input as a string.
#
Return Object (awaited):pid
Number: Process identifier.stdOut
String: Standard output.stdErr
String: Standard error.exitCode
Number: Exit code of the process.
#
os.spawnProcess(command)Spawns a process based on a command in background and let developers control it.
#
Parameterscommand
String: The command that is to be executed in a new process.
#
Return Object (awaited):id
Number: A Neutralino-scoped process identifier. This value is used for controlling the process via the native API.pid
Number: Process identifier from the operating system.
#
os.updateSpawnedProcess(id, action, data)Updates a spawned process based on a provided action and data. Throws NE_OS_UNLTOUP
if the process cannot be
updated.
#
Parametersid
Number: Neutralino-scoped process identifier.action
String: An action to take. Accepts only the following values:stdIn
: Sends data to the process via the standard input stream.stdInEnd
: Closes the standard input stream file descriptor.exit
: Terminates the process.
data
Object (optional): Additional data for theaction
. Send stardard input string if theaction
isstdIn
.
#
os.getSpawnedProcesses()Returns all spawned processes.
#
Return Object (awaited):An array of SpawnedProcess
objects.
#
SpawnedProcessid
Number: A Neutralino-scoped process identifier..pid
Number: Process identifier from the operating system.
#
os.getEnv(key)Provides the value of a given environment variable.
#
Parameterskey
String: The name of the environment variable.
#
Return String (awaited):Value of the given environment variable. Returns an empty string if the environment variable is not defined.
#
os.getEnvs()Returns all environment variables and their values.
#
Return Object (awaited):Environment variables details in key-value pairs.
#
os.showOpenDialog(title, options)Shows the file open dialog. You can use this function to obtain paths of existing files.
#
Parameterstitle
String (optional): Title of the dialog.
#
Optionsfilters
Filter[] (optional): An array of Filter objects to filter the files list.multiSelections
(optional): Enables multi selections.defaultPath
String (optional): Initial path/filename displayed by the dialog.
#
Filtername
String: Filter name.extensions
String: Array of file extensions. Eg:['jpg', 'png']
#
Return Object (awaited):An array of selected entries.
#
os.showSaveDialog(title, options)Shows the file save dialog. You can use this function to obtain a path to create a new file.
#
Parameterstitle
String (optional): Title of the dialog.
#
Optionsfilters
Filter[] (optional): An array of Filter objects to filter the files list.forceOverwrite
Boolean (optional): Skips file overwrite warning message.defaultPath
String (optional): Initial path/filename displayed by the dialog.
#
Filtername
String: Filter name.extensions
String[]: Array of file extensions. Eg:['jpg', 'png']
#
Return String (awaited):Selected filename.
#
os.showFolderDialog(title)Shows the folder open dialog.
#
Parameterstitle
String (optional): Title of the dialog.
#
OptionsdefaultPath
String (optional): Initial path displayed by the dialog.
#
Return String (awaited):Selected folder.
#
os.showNotification(title, content, icon)Displays a notification message.
#
Parameterstitle
String: Notification title.content
String: Content of the notification.icon
String (optional): Icon name. Accpeted values are:INFO
,WARNING
,ERROR
, andQUESTION
. The default value isINFO
#
os.showMessageBox(title, content, choice, icon)Displays a message box.
#
Parameterstitle
String: Title of the message box.content
String: Content of the message box.choice
String (optional): Message box buttons. Accpeted values are:OK
,OK_CANCEL
,YES_NO
,YES_NO_CANCEL
,RETRY_CANCEL
, andABORT_RETRY_IGNORE
. The default value isOK
.icon
String (optional): Icon name. Accpeted values are:INFO
,WARNING
,ERROR
, andQUESTION
. The default value isINFO
.
#
Return String (awaited):User's choice
.
#
os.setTray(options)Creates/updates the tray icon and menu.
#
Optionsicon
String: Tray icon path. Eg:/resources/icons/trayIcon.png
. A20x20
-sized PNG image file works fine on all supported operating systems.menuItems
TrayMenuItem[]: An array ofTrayMenuItem
objects.
#
TrayMenuItemid
String (optional): A unique identifier for each menu item.text
String: Label of the menu item. This field is a mandatory field. Use-
(hyphen) character for a menu separator.isDisabled
Boolean (optional): A boolean flag to disable/enable a specific menu item.isChecked
Boolean (optional): A boolean flag to mark a specific menu item as selected.
#
os.getPath(name)Returns known platform-specific folders such as Downloads, Music, Videos, etc.
#
Parameterstitle
String: Name of the folder. Accepted values are:config
,data
,cache
,documents
,pictures
,music
,video
,downloads
,savedGames1
, andsavedGames2
. ThrowsNE_OS_INVKNPT
for invalid folder names.
#
Return String (awaited):Path.
#
os.open(url)Opens a URL with the default web browser.
tip
If your application is running in the default web browser, this method will open a new tab.
#
Parametersurl
String: URL to be opened.