> For the complete documentation index, see [llms.txt](https://stage-precision.gitbook.io/grid/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stage-precision.gitbook.io/grid/scripting/api-reference/utility-api/system-and-application.md).

# System & Application

### `getAppVersion()`

Returns the current Grid Studio version.

#### Syntax

```python
sp.util.getAppVersion()
```

#### Returns

`str`

#### Example

```python
version = sp.util.getAppVersion()

print(version)
```

Example result:

```
2.2.5
```

### `getEnvironmentVariable()`

Returns the value of a system environment variable.

#### Syntax

```python
sp.util.getEnvironmentVariable(name)
```

#### Parameters

| Parameter | Type  | Description                      |
| --------- | ----- | -------------------------------- |
| `name`    | `str` | Name of the environment variable |

#### Returns

`str`

#### Example

```python
username = sp.util.getEnvironmentVariable(
    "USERNAME"
)

print(username)
```

### `getIPs()`

Returns IP addresses reported by the system.

#### Syntax

```python
sp.util.getIPs()
```

#### Returns

`list`

A list containing IP addresses as strings.

#### Example

```python
ips = sp.util.getIPs()

for ip in ips:
    print(ip)
```

{% hint style="info" %}
The returned list may contain different address types, including local, link-local, loopback or multicast addresses.
{% endhint %}

### `getOSInfos()`

Returns information about the operating system and current machine.

#### Syntax

```python
sp.util.getOSInfos()
```

#### Returns

`dict`

The returned Dictionary contains:

| Key            | Type  | Description                    |
| -------------- | ----- | ------------------------------ |
| `name`         | `str` | Operating system name          |
| `type`         | `int` | Internal operating system type |
| `computerName` | `str` | Computer name                  |
| `language`     | `str` | System language                |
| `username`     | `str` | Current user name              |

#### Example

```python
info = sp.util.getOSInfos()

print(info["name"])
print(info["computerName"])
print(info["language"])
print(info["username"])
```

Example structure:

```python
{
    "name": "Windows 11",
    "type": 520,
    "computerName": "ComputerName",
    "language": "en",
    "username": "User"
}
```

{% hint style="info" %}
The numeric value returned as `type` is an internal operating system identifier.
{% endhint %}

### `getTime()`

Returns the number of seconds since the operating system was started.

#### Syntax

```python
sp.util.getTime()
```

#### Returns

`float`

#### Example

```python
uptime = sp.util.getTime()

print(uptime)
```

Example result:

```
359173.09375
```

The returned value represents system uptime in seconds.

### `getTimestamp()`

Returns the current Unix timestamp.

#### Syntax

```python
sp.util.getTimestamp()
```

#### Returns

`int`

The number of seconds since **January 1, 1970 UTC**.

#### Example

```python
timestamp = sp.util.getTimestamp()

print(timestamp)
```

### `copyToClipboard()`

Copies text to the system clipboard.

#### Syntax

```python
sp.util.copyToClipboard(value)
```

#### Parameters

| Parameter | Type  | Description                   |
| --------- | ----- | ----------------------------- |
| `value`   | `str` | Text to copy to the clipboard |

#### Returns

`str`

Returns the supplied string.

#### Example

```python
result = sp.util.copyToClipboard(
    "Grid Studio Scripting Test"
)

print(result)
```

### `getFromClipboard()`

Returns the current text content of the system clipboard.

#### Syntax

```python
sp.util.getFromClipboard()
```

#### Returns

`str`

#### Example

```python
value = sp.util.getFromClipboard()

print(value)
```

{% hint style="info" %}
Clipboard updates may not be available immediately after calling `copyToClipboard()`. If a script writes and then immediately reads the clipboard, a short delay may be required.
{% endhint %}

### `launchFile()`

Opens a file or launches an application using the specified path.

#### Syntax

```python
sp.util.launchFile(path)
```

#### Parameters

| Parameter | Type  | Description                     |
| --------- | ----- | ------------------------------- |
| `path`    | `str` | Path to the file or application |

#### Returns

`bool`

Returns `True` when the file or application was launched successfully, otherwise `False`.

#### Example

```python
result = sp.util.launchFile(
    "C:/Windows/System32/notepad.exe"
)

print(result)
```

### `killApp()`

Closes a running application by process name.

#### Syntax

```python
sp.util.killApp(processName)
```

#### Parameters

| Parameter     | Type  | Description                              |
| ------------- | ----- | ---------------------------------------- |
| `processName` | `str` | Process name of the application to close |

#### Returns

`None`

#### Example

```python
sp.util.killApp("notepad.exe")
```

{% hint style="warning" %}
`killApp()` terminates the specified application process. Unsaved data in that application may be lost.
{% endhint %}

### Quick Reference

| API                                    | Returns | Description                                      |
| -------------------------------------- | ------- | ------------------------------------------------ |
| `sp.util.getAppVersion()`              | `str`   | Returns the Grid Studio version                  |
| `sp.util.getEnvironmentVariable(name)` | `str`   | Returns a system environment variable            |
| `sp.util.getIPs()`                     | `list`  | Returns IP addresses reported by the system      |
| `sp.util.getOSInfos()`                 | `dict`  | Returns operating system and machine information |
| `sp.util.getTime()`                    | `float` | Returns system uptime in seconds                 |
| `sp.util.getTimestamp()`               | `int`   | Returns the current Unix timestamp               |
| `sp.util.copyToClipboard(value)`       | `str`   | Copies text to the system clipboard              |
| `sp.util.getFromClipboard()`           | `str`   | Returns text from the system clipboard           |
| `sp.util.launchFile(path)`             | `bool`  | Opens a file or launches an application          |
| `sp.util.killApp(processName)`         | `None`  | Terminates an application process                |
