bt_app Complete example
bt_app Complete example
Pure local HTML desktop application
File structure:
html-demo/ index.html
index.html:
<!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> </head> <body> <h1>HTML Demo</h1> </body> </html>
Run:
./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:
static-demo/ app.json index.html main.bt
app.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:
fn add(args) { return { error:false, message:'ok', data:args.a + args.b } }
index.html:
<!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>Static Demo</title> </head> <body> <button id="btn">Calculate</button> <pre id="out"></pre> <script> document.getElementById('btn').onclick = async () => { const result = await window.bt.call('add', { a: 20, b: 22 }); document.getElementById('out').textContent = JSON.stringify(result, null, 2); }; </script> </body> </html>
Local BT service plus Web page
File structure:
server-demo/ app.json server.bt main.bt www/ main.bt index.bt
app.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:
net.listen({ type:'web' bind:'127.0.0.1:18280' sites:[ { domains:['127.0.0.1'] root:'www/' entry:'main.bt' } ] })
www/main.bt:
include('www/index.bt')
www/static/index.bt:
# TPL home page <!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>Server Demo</title> </head> <body> <h1>Server Demo</h1> </body> </html>
Remote Web application packaging
app.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:
{ "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 throughwindow.bt.app.run().
- 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:
cd examples/desktop-screen-tools ..\..\target\release\bt_app.exe
Build a single file application:
..\..\target\release\bt_app.exe build
You can also generate only the toolbar BTR:
..\..\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.