@bobfrankston/邮件
用于Node.js应用的快速,轻量级信息箱.
以简单的 JavaScript API 显示本地信件框、对话框和 HTML 内容 。 作品有Windows,Linux(x64)和Linux(ARM64/Raspberry Pi).
快速链接
- 安装 - 开始吧
- 命令行使用量 - 从 shell 脚本使用
- 节点.js API - 从 JavaScript/ TypeScript 使用
- 对于开发者 - 建筑和建筑
- 路线图 - 技术状况和计划特点
安装
npm install @bobfrankston/msger
用于全球CLI:
npm install -g @bobfrankston/msger
支持的平台:
- 视窗 (x64)
- Linux (x64) (英语)
- Linux (ARM64 / Raspberry Pi) (韩语)
命令行使用量
这个 msger 命令行工具提供了从 shell 脚本,分批文件,或终端显示消息框的快取方式.
基本实例
# Simple message
msger -message "Hello, World!"
msger Hello World # shorthand - words become message
# With HTML content
msger -html "<h1>Welcome!</h1><p>This is <strong>HTML</strong></p>"
# Colored text with inline styles
msger -html "<span style='color:red;background-color:yellow'>Alert!</span>"
# Load a URL (web page, local file, or a directory's index.html)
msger -url "https://example.com"
msger -url "file:///path/to/page.html"
msger -url ./site # serves ./site/index.html and its sibling assets
# Render a local markdown file — use the mdview wrapper (msger doesn't auto-render .md)
mdview todo.md
# Display arbitrary HTML as a complete page (no template, no buttons) — used by mdview
msger -raw -html "<!doctype html><html>...</html>"
# Load URL with hash fragment
msger -url "https://example.com" -hash section1
msger -url "https://example.com" -hash "#intro"
# With input field and placeholder
msger -message "Enter your name:" -input "Your name here" -default "John"
# Custom buttons
msger -message "Save changes?" -buttons Yes No Cancel
# With custom size and position
msger -message "Hello" -size 800,600 -pos 100,100
# Always on top with zoom
msger -message "Important!" -ontop -zoom 150
# Detached URL browser (stays open after script exits)
msger -url "https://example.com" -detach
# Fullscreen mode
msger -fullscreen -url "https://example.com"
# Multi-monitor - show on second screen
msger -message "Second screen" -pos 0,100 -screen 1
# What displays are there? (JSON, no window; indices match -screen)
msger -list
# Transparent click-through overlay on screen 1, gone after 3 seconds
msger -overlay -fullscreen -screen 1 -timeout 3 "1"
# Number every screen, the way the display settings "Identify" button does
msger -list | ConvertFrom-Json | ForEach-Object { $_.monitors } | ForEach-Object {
Start-Process msger -ArgumentList "-overlay -fullscreen -screen $($_.index) -timeout 3 `"$($_.index + 1)`""
}
# Auto-close timeout
msger -message "Closing in 5 seconds..." -timeout 5
# Open with DevTools for debugging (automatically opens DevTools panel)
msger -url "https://example.com" -dev
# See all options
msger --help
无头模式( E)-noshow)——以WebView为CSS/JS引擎
-noshow 不打开可见窗口, 但 WebView 仍然装入 HTML, 运行 <script> 块,并解析 CSS —— 这样一个嵌入式脚本就可以查询引擎,并通过 window.ipc.postMessage结合 -result <fieldname> 来打印一个字段,这可以让你使用 msger 作为无头渲染引擎 用于类似的东西 contrast-color(), (中文(简体) ), getComputedStyle(),以及 CSS.supports()。 。 。 .
# Resolve contrast-color() — needs a DOM element + getComputedStyle because
# CSS functions only resolve through the cascade.
msger -noshow -html '<div id=x style="color:contrast-color(steelblue)"></div>
<script>
requestAnimationFrame(() => requestAnimationFrame(() => {
window.ipc.postMessage(JSON.stringify({
button: "r",
value: getComputedStyle(document.getElementById("x")).color
}));
}));
</script>' -result value
# → rgb(255, 255, 255)
节点API同样工作方式——通过 noshow: true 财务报告和审定财务报表 html: "..." 改为 showMessageBox,然后读取 result.value 以坚忍的盟誓盟誓.
注释:
-result <fieldname>打印字段的值(字符串为-is,其他类型为JSON-stringifed),而不是完整MessageBoxResult贾森。 用来消耗外壳.- 两者
requestAnimationFrame调用让布局在读取计算样式之前结算——需要用于contrast-color,渐变等. - 原画
-noshow -save行为没有改变:它保存后仍然退出,从未创建过WebView.
渲染模式( E)-render)——抓取页面到图像
-render 将 msger 转换为无头页面 – bitmap 渲染器: 从未出现过窗口; 页面负载、 结算、 截图和 msger 退出 。 视窗 (WebView2, CDP) Page.captureScreenshot)和Linux/Pi(WebKitGTK快照). 在Mac上没有支持.
# Write a PNG of a web page (format follows the extension: .png/.jpg/.bmp)
msger -url "https://example.com" -size 1024,768 -render page.png
# Render inline HTML (charts, badges, generated markup)
msger -html "<h1 style='color:steelblue'>Build OK</h1>" -size 400,150 -render status.png
# No file → the image comes back base64 in the JSON result
msger -message "hello" -render
# → { "button": "render", "render": { "format": "png", "data": "iVBOR...", "width": 500, "height": 375 } }
节点 API 镜像此:
// Write a file; result.render = { path, width, height, format }
await showMessageBox({ url: "https://example.com", size: { width: 1024, height: 768 }, render: "page.png" });
// Or get the image as an object; result.render = { data (base64), width, height, format }
const result = await showMessageBox({ html: "<h1>Chart</h1>", render: true });
fs.writeFileSync("out.png", Buffer.from(result.render!.data!, "base64"));
注释:
- 页面之后的捕捉火灾
load事件+2requestAnimationFrames + 结算延迟(renderDelay选项,默认为100ms)。 如果这页从不开火load,msger在超时(渲染模式中的默认为30s)时抓取最佳效果. - Width/height是物理像素——125%的DPI显示抓取500×375上的400×300窗口.
renderFormat(单位:千美元)png编号 :jpeg编号 :bmp)可以在API中明确设置;CLI来源于文件扩展名.- 一个失败的抓取拒绝了承诺(CLI:stderr上的错误,非零退出).
- msgview 支持同样的
-render选项通过 Electron'scapturePage()在它的平台上. -render抓取 视图 (窗户大小. 要抓取整个文档,包括卷出视图的内容,请使用 缩写+ 移动+S / 在可见窗口中右键单击"保存页面图像"(见键盘快捷键). 该路径只写一个文件到您的 Pictures 文件夹; 任何信息都无法返回呼叫者 .- 有一个 没有 API 可按要求抓取活窗口 (从JS通过)
msgapi,或者从母进程),并获取图像作为缓冲. 伦德模式为一发:抓取后退出. - 只抓取了页面,从不抓取桌面或其他窗口.
(Claude Code更新了第2026-11-05节,Opus 5.5:添加了Linux/Pi,Mac,viewport vs. full page,和缺失的活捉API
JSON 配置文件
您可以将消息框配置存储在 JSON 文件, 以供再使用 。 JSON文件支持注释(JSON5格式).
# Load configuration from file
msger -load config.json
# Override specific values from loaded config
msger -load config.json -title "New Title" -size 800,600
# Save current command-line options to a file (only saves explicitly specified values)
msger -title "My Dialog" -message "Hello" -buttons Yes No -save my-config.json
# Save config without showing the message box (uses -noshow)
msger -title "My Dialog" -message "Hello" -buttons Yes No -save my-config -noshow
# Load base config, override, and save the overrides
msger -load base.json -title "Modified" -save modified.json
# Save and show (saves config then displays the message box)
msger -title "Test" -message "Saving config..." -save test.json
注释:
- 这个
-save选项只保存明确指定的命令行参数,而不是衍生出默认值。 这将配置文件保持在最低限度,并允许默认进化. -noshow与-save写入配置和退出而不创建 WebView 。 无-save, (中文(简体) ),-noshow创建WebView并运行脚本,但不打开可见窗口——用于无头CSS/JS解析(见下文"无头模式").- 文件扩展名: 如果您不指定
.json,将自动添加(例如,myconfig变成myconfig.json) (中文(简体) ).
完整的JSON结构
{
"title": "Window Title",
"message": "Plain text message (supports ANSI color codes)",
"html": "<h1>HTML content</h1><p>Rich formatting</p>",
"url": "https://example.com",
"hash": "section1",
"size": {
"width": 600,
"height": 400
},
"pos": {
"x": 100,
"y": 100,
"screen": 0
},
"buttons": ["Cancel", "OK"],
"defaultValue": "default input text",
"inputPlaceholder": "Enter text here...",
"allowInput": false,
"timeout": 30,
"autoSize": false,
"alwaysOnTop": false,
"fullscreen": false,
"zoom": 100,
"debug": false,
"icon": "path/to/icon.png",
"dev": false
}
实地参考
| 外地 | 类型 | 默认 | 说明 |
|---|---|---|---|
title | 字符串 | "记忆" | 窗口标题 |
message | 字符串 | 无效 | 纯文本消息( 支持 ANSI 颜色代码) |
html | 字符串 | 无效 | 要显示的 HTML 内容 |
url | 字符串 | 无效 | 要装入的 URL (web 或文件 ://) |
hash | 字符串 | 无效 | 添加到 URL( 需要 URL) 的散列片段 。 领跑#是可选的. |
size | 对象 | {"width": 600, "height": 400} | 窗口大小 |
size.width | 编号 | 600个(或1024个URL) | 窗口宽度, 像素 |
size.height | 编号 | 400个(或768个URL) | 窗口高度( 像素) |
pos | 对象 | 无效 | 窗口位置 |
pos.x | 编号 | - 说吧 | X 像素坐标 |
pos.y | 编号 | - 说吧 | Y 像素坐标 |
pos.screen | 编号 | 无效 | [只有窗口]屏幕指数(0=主,1=秒等) |
buttons | 字符串 [] | ["好吧"] | 按钮标签 |
defaultValue | 字符串 | 无效 | 默认输入值 |
inputPlaceholder | 字符串 | 无效 | 输入字段的占位符文本 |
allowInput | 布尔 | 虚假 | 显示输入字段 |
timeout | 编号 | 无效 | N 秒后自动关闭 |
autoSize | 布尔 | 无大小时为真 | 自动调整窗口以适应内容 |
alwaysOnTop | 布尔 | 虚假 | 保持窗口上方 |
fullscreen | 布尔 | 虚假 | 以全屏模式启动 |
screen | 编号 | 无效 | 监视器指数(基于0) fullscreen后退时 pos.screen。选择显示的可移植方式——Wayland拒绝客户端设置窗口坐标,但在选定的输出上尊重全屏 |
overlay | 布尔 | 虚假 | 无框架,透明,点击通过,总是从桌面上取出窗口,远离任务栏,从不集中. 与 timeout ——它没有关闭按钮并经过点击,所以里面没有任何东西可以操作. 与 url编号 :rawHtml 页面必须设置自己的透明背景;内置模板已经设置了。 每个覆盖都获得自己的WebView2配置文件(由屏幕键入),这样可以同时开始一组配置文件 |
listMonitors | 布尔 | 虚假 | 打印显示器布局为 JSON 并退出而不打开窗口 : {"monitors":[{index,name,x,y,width,height,scale,primary}]} |
zoom | 编号 | 100个 | 初始缩放水平(100=100%,150=150%). 应用在每个模式——消息、 HTML 和 URL |
newWindow | 字符串 | "browser" | 在哪里"在新窗口打开" / target=_blank 链接去 : "browser" (系统浏览器)或 "msger" (弹出另一个msger窗口) |
contextMenu | 字符串 | "page" | "always" 将本地右键单击菜单强制到任何地方,即使页面用自己的页面压制它 contextmenu 处理器 |
showVersion | 布尔 | 虚假 | 保留 msger vX.Y.Z 标题栏的附件,当页面更改自己的标题时重新应用 |
debug | 布尔 | 虚假 | 结果返回调试信息 |
noResult | 布尔 | 虚假 | JSON Studout上的结果( 错误仍为 stderr ) |
icon | 字符串 | 无效 | 窗口图标路径 (.png,.ico) |
dev | 布尔 | 虚假 | 自动打开 DevTools( 用于调试 HTML/ URL 内容) |
内容优先级 : 仅显示一个内容类型( 按顺序):
url- 如果提供,则装入 URL(ignores message/html)html- 如果提供,则显示 HTML(ignores 消息)message- 有 ANSI 颜色支持的纯文本
向后兼容性 : 旧的 width 财务报告和审定财务报表 height 字段(在顶层)仍然支持后向兼容,但 size 对象首选。 如果两者都提供, size 以优先为准.
JSON 实例
简单对话框 :
{
"title": "Confirm",
"message": "Are you sure?",
"buttons": ["Cancel", "OK"]
}
输入对话框 :
{
"title": "Enter Name",
"message": "Please enter your name:",
"allowInput": true,
"inputPlaceholder": "Your name here",
"defaultValue": "John Doe",
"buttons": ["Cancel", "Submit"]
}
HTML 内容 :
{
"title": "Welcome",
"html": "<h1>Welcome!</h1><p>Getting started...</p>",
"size": {
"width": 700,
"height": 500
}
}
在第二个显示器上设置窗口 :
{
"message": "Second screen",
"pos": {
"x": 0,
"y": 100,
"screen": 1
}
}
CLI 选项参考
Usage: msger [options] [message words...]
Options:
-message, --message <text> Plain text message
-title, --title <text> Window title
-html, --html <html> HTML content
-url, --url <url> URL to load (web, local file, or directory → its index.html)
-hash, --hash <fragment> Hash fragment to append to URL (requires -url). Leading # optional.
-buttons, --buttons <labels> Button labels (e.g., -buttons Yes No Cancel)
-ok, --ok Add OK button
-cancel, --cancel Add Cancel button
-input, --input [placeholder] Include input field with optional placeholder text
-default, --default <text> Default value for input field
-size, --size <width,height> Window size (e.g., -size 800,600)
-pos, --pos <x,y> Window position (e.g., -pos 100,200)
-screen, --screen <number> Screen index (0=primary, 1=second, etc.). Offsets -pos into
that screen, and picks which screen -fullscreen covers.
-list, --list Print the monitor layout as JSON and exit (no window)
-zoom, --zoom <percent> Zoom level as percentage (e.g., -zoom 150 for 150%).
Works in message, HTML and URL modes alike.
-newwindow, --newwindow <where> Where "open in new window" links go:
browser (default) or msger (spawn another msger window)
-timeout, --timeout <seconds> Auto-close after specified seconds
-ontop, --ontop Keep window always on top
-detach, --detach Launch window independently (parent returns immediately)
-fullscreen, --fullscreen Start window in fullscreen mode (F11 to toggle, Escape to exit)
-overlay, --overlay Frameless, transparent, click-through window over the desktop.
Always on top, no taskbar slot, never takes focus. Pair with
-timeout; combine with -fullscreen -screen <n> per display.
-raw, --raw With -html: load HTML as-is, no msger template/buttons (alias: -full)
-debug, --debug Return debug info (HTML, size, autoSize) in result
-render, --render [file] Render the page to a bitmap instead of displaying it.
With <file>, writes the image (.png/.jpg/.bmp by extension);
without, returns it base64 in result.render. [Windows, Linux/Pi]
-noshow, --noshow Don't display the window. With -save, exits after saving.
Otherwise the WebView still loads + runs scripts so a page
can post a result via window.ipc.postMessage; only the
window isn't shown. Useful for headless CSS/JS resolution.
-noresult, --noresult Suppress JSON result output on stdout (errors still go to stderr)
-result, --result [fieldname] Re-enable result output. With <fieldname>, print just that
field (e.g. -result value → bare string). Strings print as-is,
other types JSON-stringify. Missing field → exit 2.
-v, -version, --version Show version number
-help, -?, --help Show help message
Keyboard Shortcuts:
- Enter: Click default (last) button
- Escape: Dismiss dialog or exit fullscreen
- F11: Toggle fullscreen mode
- F12: Open developer tools (DevTools/Inspect)
- Ctrl+Wheel/Plus/Minus: Zoom in/out (×1.25 per step, so in-then-out returns
exactly to where you started). The host owns the zoom factor — the system
menu's zoom items, -zoom and these keys all drive the same value.
- Ctrl+0: Reset zoom to 100%
- Ctrl+Shift+S: Save an image of the WHOLE page — including whatever is
scrolled out of view — to your Pictures folder. The path is printed to
stderr and copied to the clipboard (Windows). Also on the right-click menu
as "Save page image".
Debug Mode:
- Set environment variable MSGER_DEBUG=1 for diagnostic output
- Shows: startup info, keyboard events, IPC messages, button clicks
- Example (PowerShell): $env:MSGER_DEBUG=1; msger "Test"
- Zero performance impact when disabled
Notes:
- If no options provided, all non-option arguments are concatenated as message
- Press ESC to dismiss (returns button: "dismissed")
- Press Enter to click last (default) button
- OK button is green by default
- URLs default to 1024x768 window size
- Window title automatically updates from loaded page's <title> tag when using -url
- Local pages given to -url are served from their own directory over
http://msger.localhost/ rather than file:// (file:// pages cannot use the
msgapi IPC bridge at all — WebView2 aborts on them)
- Right-click → "Copy URL" copies the address of the current page; for local
content it copies the file's path on disk
- The loaded page's favicon becomes the window + taskbar icon (Windows);
pass -icon to keep your own icon instead
- Windows auto-size to fit content when size not specified
- Runtime zoom: Ctrl+Wheel, Ctrl+Plus, Ctrl+Minus
节点.js API 参考
在您的 Node.js 或 TypeScript 应用程序中使用 msger , 并使用简单的基于 API 的 Profession .
快速启动
import { showMessageBox } from '@bobfrankston/msger';
const result = await showMessageBox({
title: 'Confirm Action',
message: 'Are you sure you want to proceed?',
buttons: ['Cancel', 'OK']
});
console.log('User clicked:', result.button);
if (result.value) {
console.log('User entered:', result.value);
}
程序关闭 API (New!)
从父进程程序上关闭消息框 :
基于处理的 API( 建议):
import { showMessageBoxEx } from '@bobfrankston/msger';
const handle = showMessageBoxEx({
message: 'Processing...',
buttons: ['Cancel']
});
console.log('Dialog PID:', handle.pid);
// Close after 5 seconds
setTimeout(() => {
handle.close();
}, 5000);
// Wait for result
const result = await handle.result;
// Result: {button: 'closed', closed: true} if closed programmatically
// Result: {button: 'Cancel'} if user clicked Cancel
独立的近距离函数 :
import { showMessageBoxEx, closeMessageBox } from '@bobfrankston/msger';
const handle = showMessageBoxEx({ message: 'Working...' });
const pid = handle.pid;
// Close by PID from anywhere
closeMessageBox(pid);
使用大小写 :
- 任务完成后自动关闭的进程对话框
- 基于超时的通知
- PID 管理多个对话框
- 离线对话框远程关闭
见 关闭-API.md 用于完整文档.
API 函数
showMessageBox(options: MessageBoxOptions): Promise<MessageBoxResult>
显示消息框对话框并等待用户回复 .
信件框选项
interface MessageBoxOptions {
title?: string; // Window title (default: "Message")
message?: string; // Plain text message (optional if url or html provided)
html?: string; // HTML content to display
url?: string; // URL to load (web URL or file:// path)
hash?: string; // Hash fragment to append to URL (requires url). Leading # optional.
size?: { // Window size in pixels
width: number; // Window width (default: 600, or 1024 for URLs)
height: number; // Window height (default: 400, or 768 for URLs)
};
pos?: { // Window position
x: number; // X coordinate in pixels
y: number; // Y coordinate in pixels
screen?: number; // [Windows only] Screen index (0=primary, 1=second, etc.)
};
buttons?: string[]; // Button labels (default: ["OK"])
defaultValue?: string; // Default input value
inputPlaceholder?: string; // Placeholder text (gray hint) for input field
allowInput?: boolean; // Show input field (default: false)
autoSize?: boolean; // Auto-resize window to fit content (default: true when no size specified)
alwaysOnTop?: boolean; // Keep window on top of other windows (default: false)
zoom?: number; // Initial zoom level (100=100%, 150=150%, 50=50%)
timeout?: number; // Auto-close after N seconds
detach?: boolean; // Launch detached from parent process
fullscreen?: boolean; // Start window in fullscreen mode (F11 to toggle)
rawHtml?: boolean; // With html: load HTML as-is, no msger template/buttons (used by mdview). CLI: -raw
debug?: boolean; // Return debug info (HTML, size, autoSize) in result
noResult?: boolean; // Suppress JSON result on stdout (CLI: -noresult, -result re-enables)
render?: boolean | string; // Render to a bitmap instead of displaying. String = file to write
// (format from extension), true = base64 object in result.render.
renderDelay?: number; // Render mode: ms between page load and capture (default 100)
renderFormat?: string; // Render mode: png (default) | jpeg | bmp
}
信件框结果
interface MessageBoxResult {
button: string; // Label of clicked button
value?: string; // Input value (if allowInput was true)
form?: object; // Form data (if form elements present)
closed?: boolean; // True if closed programmatically via handle.close()
dismissed?: boolean; // True if user pressed Escape
timeout?: boolean; // True if closed due to timeout
bounds?: { // Virtual-desktop window geometry at close (pixels).
// x,y are single-plane coords across all monitors — NOT
// monitor-relative + screen index. Feed straight back into
// `-pos bounds.x,bounds.y`. See msgcommon/README.md.
x: number;
y: number;
width: number;
height: number;
};
debug?: { // Debug info (if debug option was true)
html: string; // Generated HTML content
width: number; // Window width
height: number; // Window height
autoSize: boolean; // Whether auto-sizing is enabled
};
render?: { // Captured screenshot (render mode)
format: string; // png | jpeg | bmp
width: number; // Physical pixels (includes DPI scale)
height: number;
data?: string; // Base64 image bytes (render: true)
path?: string; // Absolute path of written file (render: "file")
};
renderError?: string; // Why render produced no image (the promise rejects with this)
}
API 示例
简单确认对话框
const result = await showMessageBox({
title: 'Delete File',
message: 'Are you sure you want to delete this file?',
buttons: ['Cancel', 'Delete']
});
if (result.button === 'Delete') {
// Perform deletion
}
输入对话框
const result = await showMessageBox({
title: 'Enter Name',
message: 'Please enter your name:',
allowInput: true,
inputPlaceholder: 'Your name here',
defaultValue: 'John Doe',
buttons: ['Cancel', 'OK']
});
if (result.button === 'OK') {
console.log('Name entered:', result.value);
}
HTML 内容
const result = await showMessageBox({
title: 'Welcome',
html: `
<div style="font-family: sans-serif;">
<h2 style="color: #2563eb;">Welcome!</h2>
<p>This supports <strong>HTML</strong> content.</p>
<ul>
<li>Rich formatting</li>
<li>Custom styles</li>
<li>Any HTML elements</li>
</ul>
</div>
`,
size: { width: 700, height: 500 },
buttons: ['Close']
});
ANSI 颜色代码
纯文本信息自动支持 ANSI 色彩逃逸序列, 这些序列被转换为 HTML , 并带有适当的颜色 :
const result = await showMessageBox({
title: 'Color Test',
message: '\x1b[31mRed text\x1b[0m\n\x1b[32mGreen text\x1b[0m\n\x1b[1m\x1b[34mBold blue\x1b[0m',
buttons: ['OK']
});
支持的 ANSI 代码 :
- 颜色:红(31),绿(32),黄(33),蓝(34),红(35),青(36),白(37)
- 样式: 粗体(1),下行(4),重置(0)
- 背景情况: 40-47 (与前缘同色号)
CLI 实例 :
echo -e "\x1b[31mError:\x1b[0m Something went wrong" | msger
显示网页
// Load external website
// Note: Window title automatically updates from page's <title> tag
await showMessageBox({
url: 'https://github.com/BobFrankston/msger',
size: { width: 1024, height: 768 }
});
// Load local HTML file
await showMessageBox({
url: 'file:///path/to/help.html',
size: { width: 800, height: 600 }
});
// Load with DevTools opened automatically (for debugging)
await showMessageBox({
url: 'https://example.com',
dev: true, // Opens DevTools automatically
size: { width: 1024, height: 768 }
});
自动关闭超时
// Show notification that auto-closes after 3 seconds
// A translucent countdown indicator appears in the top-right corner
const result = await showMessageBox({
title: 'Notification',
message: 'File saved successfully!',
timeout: 3,
buttons: ['OK']
});
if (result.timeout) {
console.log('Notification auto-closed');
}
倒计时器在右上角显示为微妙的黄色徽章,显示所剩秒(如"10","9","8"等).
HTML 窗体
const result = await showMessageBox({
title: 'User Registration',
html: `
<form>
<label>Name: <input name="name" required /></label><br>
<label>Email: <input name="email" type="email" required /></label><br>
<label>Age: <input name="age" type="number" /></label>
</form>
`,
buttons: ['Cancel', 'Submit']
});
if (result.button === 'Submit' && result.form) {
console.log('Name:', result.form.name);
console.log('Email:', result.form.email);
console.log('Age:', result.form.age);
}
窗口定位
// Position at specific coordinates
await showMessageBox({
message: 'Positioned window',
pos: { x: 100, y: 100 }
});
// Position on second monitor (Windows only)
await showMessageBox({
message: 'On second screen',
pos: { x: 0, y: 100, screen: 1 }
});
总是在顶部缩放( Z)
// Keep window on top with 150% zoom
await showMessageBox({
title: 'Important Alert',
message: 'This window stays on top!',
alwaysOnTop: true,
zoom: 150
});
自动缩放窗口
// Window automatically sizes to fit content
await showMessageBox({
message: 'Short message',
autoSize: true // default when size not specified
});
已调试的 URL 浏览器
// Launch URL window that stays open after script exits
await showMessageBox({
url: 'https://example.com',
size: { width: 1200, height: 800 },
detach: true,
alwaysOnTop: true
});
// Script continues/exits immediately, window stays open
全屏模式
// Launch window in fullscreen mode (like F11 in browser)
await showMessageBox({
url: 'https://example.com',
fullscreen: true
});
// Users can press F11 to toggle fullscreen or Escape to exit
// Fullscreen with message
await showMessageBox({
message: 'Full screen presentation',
fullscreen: true,
buttons: ['Close']
});
特征
- QQ 显示纯文本、 HTML 内容或装入 URL
- QQ 完整 HTML/ CSS 支持
- * ANSI 颜色代码(彩色终端输出)
- QQ 自定义按钮
- 输入字段和表格
- QQ 自动关闭超时
- 窗口定位和大小
- 多监视器支持( Windows)
- 总是在顶端模式
- 缩放控制
- QQ 全屏模式
- QQ 类型脚本类型定义
- 键盘快捷键( Enter, Escape, F11, F12)
为什么是Msger?
- 快点 -200米以下的开口
- 小型 - 只安装了几台MB
- 简单 - 简便承诺的API
- 弹性 - 纯文本、 HTML 或装入 URL
- 跨平台 - 在Windows和Linux上工作
技术细节和业绩计量,见 最不发达国家。 。 。 .
msg 对 msgview 编辑器
这个包是 粗糙/粗糙 执行。 还有 @bobfrankston/ msgview 页面存档备份,存于互联网档案馆 - 具有相同API的以电子为基础的替代品.
| 侧面 | msger (这个) | 磁盘视图 |
|---|---|---|
| 启动 | ~50-200 ms (单位:千米) | ~2-3秒 |
| 大小 | ~5-10MB (5-10MB) | ~200MB 键 |
| 技术 | Rust + wry (WebView2/webkit2gtk) (中文(简体) ) | 电子 |
| 皮/ 林纳 | 编导问题 | 完美无缺 |
| 视窗/ WSL 维基月球 | 工作时间 | 工作时间 |
何时使用 msger( 此软件包)
- 速度至关重要(CLI工具、自动化)
- 小二进制大小问题
- Windows 或 WSL 环境
何时使用 msgview
- 运行在 Raspberry Pi 或 Linux 上
- 需要可靠的跨平台渲染
- 偏好电能生态系统
窗口。 msgapi
msger 注射剂 window.msgapi 输入已装入的页面 msger-api.js,提供窗口控制, DNS 查找(msgapi.dns.lookup,添加了2026-09-17),UDP网络化(host 可能是IP或主机名-同解析器),而HTTP取取. 文件系统和 shell 操作尚未在 msger 中执行 .
见 msgapidefs 读取ME 全文 window.msgapi API参考文献,执行状况及安全说明. API是实验性的,可以改变.
补充资料
重要说明
任务栏图标
图标行为差异 :
- 窗口标题栏: 显示自定义图标
-icon旗帜或 JSON 配置 - Windows 任务栏: 显示嵌入式 msger.exe 图标(运行时无法更改)
这是本地应用程序的Windows限制. 任务栏图标来自可执行器的嵌入资源,而不是运行时窗口图标. 相形之下,基于Electron的msgview可以动态地设置任务栏图标.
工作间: 计划 -pin appUserModelID 特性将允许每个被绑定的快捷键拥有自己的任务栏图标.
警卫
⚠️ msger 用于显示可信、友好的内容 (本地应用程序,您的 HTML 文件). 它不是一个安全沙盒,用于不可信/敌对的网络内容。 使用 -htmlfrom 财务报告和审定财务报表 -url 仅限信任来源.
mSG 爪哇脚本 API
最小 API - 大多数功能使用本地浏览器 API:
msger.isAvailable()- 特征检测(Msger的返回真实)msger.close()- 一样window.close()(首选本地API)
建议: 使用本地浏览器 API(localStorage, (中文(简体) ), window.close()为相容性。 代码会在任何浏览器上下文中工作,而不仅仅是MSger.
对于开发者
- 建筑( A): 见 最不发达国家
- 技术状况和路线图: 见 (单位:千美元)
- 本地二进制文档: 见 msger - 本地/README.md
许可证
公务员制度委员会
作者
鲍勃·弗兰克斯顿