# bt_app Complete example
## Pure local HTML desktop application
File structure:
```text
html-demo/
index.html
```
`index.html`:
```html
HTML Demo
```
Run:
```bash
./bt_app.exe run
```
The first run will generate the default `app.json`. The default configuration will collect `assets/**`, which can directly cover common front-end build products such as Vue/Vite. If the project also has `style.css`, `main.js`, `images/**` or other custom resources and needs to be packaged and distributed, please create your own `app.json` and write these files into `resources`.
## Local HTML plus BT function
File structure:
```text
static-demo/
app.json
index.html
main.bt
```
`app.json`:
```json
{
"app": {
"name": "StaticDemo",
"title": "Static Demo",
"mode": "static",
"entry": "index.html",
"main": "main.bt"
},
"window": {
"width": 900,
"height": 700,
"resizable": true
},
"dev": {
"watch": true,
"delay": 500,
"devtools": true,
"console": true
},
"resources": [
"index.html",
"main.bt"
],
"exclude": []
}
```
`main.bt`:
```bt
fn add(args) {
return {
error:false,
message:'ok',
data:args.a + args.b
}
}
```
`index.html`:
```html
Static Demo
```
## Local BT service plus Web page
File structure:
```text
server-demo/
app.json
server.bt
main.bt
www/
main.bt
index.bt
```
`app.json`:
```json
{
"app": {
"name": "ServerDemo",
"title": "BT Server Demo",
"mode": "server",
"entry": "http://127.0.0.1:18280",
"main": "main.bt"
},
"window": {
"width": 900,
"height": 700
},
"dev": {
"watch": true,
"delay": 500,
"devtools": false,
"console": true
},
"resources": [
"server.bt",
"main.bt",
"www/**"
],
"exclude": []
}
```
`server.bt`:
```bt
net.listen({
type:'web'
bind:'127.0.0.1:18280'
sites:[
{
domains:['127.0.0.1']
root:'www/'
entry:'main.bt'
}
]
})
```
`www/main.bt`:
```bt
include('www/index.bt')
```
`www/static/index.bt`:
```html
# TPL home page
Server Demo
Server Demo
```
## Remote Web application packaging
`app.json`:
```json
{
"app": {
"name": "RemoteDemo",
"title": "BT Remote Demo",
"mode": "remote",
"entry": "https://example.com",
"main": false
},
"window": {
"width": 1100,
"height": 760,
"resizable": true
},
"dev": {
"watch": true,
"delay": 500,
"devtools": false,
"console": false
},
"resources": [],
"exclude": []
}
```
## With icon and window configuration
`app.json`:
```json
{
"app": {
"name": "IconDemo",
"title": " application with icon in M++ ",
"version": "1.0.0",
"description": " BT desktop icon example ",
"copyright": "Copyright 2026 BT",
"mode": "static",
"entry": "index.html",
"icon": "logo.ico",
"main": false
},
"window": {
"width": 960,
"height": 640,
"resizable": true,
"fullscreen": false,
"hide_titlebar": false,
"transparent": false,
"always_on_top": false
},
"dev": {
"watch": true,
"delay": 500,
"devtools": false,
"console": false
},
"resources": [
"index.html",
"logo.ico",
"assets/**"
],
"exclude": []
}
```
The current `logo.ico` must be in the project `.ico` file.
## Screen straw and frame selection screenshots undefined in the
warehouse is a complete runnable example, providing:
- By default, the first and second slots have built-in screen straws and frame selection screenshots; `Alt+1` to `Alt+9` are always executed according to the current slot position.
- The settings menu can add `.btr` software, `.exe` and Windows `.lnk` shortcuts, and supports moving up, down, removing and restoring default tools.
- BTR uses `window.bt.app.info()` to read the app.json title and icon, and clicks or the position shortcut key to start the independent software process through `window.bt.app.run()`.
- Transparent floating toolbar without title bar, rounded corners and translucent surface drawn by HTML/CSS; supports horizontal or vertical arrangement, automatically adsorbs to the nearest edge of the screen after dragging and slides into the edge to hide after 1 second.
- The mouse automatically slides out when it touches the edge of the corresponding screen. The three-dot menu can switch directions, hide it in the tray, or exit completely; the global shortcut keys continue to respond after closing to the tray.
Run:
```powershell
cd examples/desktop-screen-tools
..\..\target\release\bt_app.exe
```
Build a single file application:
```powershell
..\..\target\release\bt_app.exe build
```
You can also generate only the toolbar BTR:
```powershell
..\..\target\release\bt_app.exe pack
..\..\target\release\bt_app.exe run .\dist\UniversalToolsDemo.btr
```
After successfully picking the color, you can press `Ctrl+V` or `Cmd+V` in the text input box to paste the color value; after successfully taking the screenshot, you can press the same shortcut key to paste the image in the chat window that supports image pasting. For detailed acceptance steps, see `README.md` in the example directory.