找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
楼主: Batcher

产生系统托盘气泡提示的批处理方法总结

[复制链接]
 楼主| 发表于 2009-4-16 11:57:04 | 显示全部楼层

回复 15楼 的帖子

1楼那个不是汇编写的,是VC写的,1楼的代码只是把它的十六进制编码用debug重新生成了exe文件而已。
发表于 2009-4-20 21:47:59 | 显示全部楼层
谢谢十六楼的大哥指点 ,用什么把源代码转换成十六进制了好呢???

[ 本帖最后由 小勇12 于 2009-4-20 21:52 编辑 ]
 楼主| 发表于 2009-4-20 22:00:54 | 显示全部楼层

回复 17楼 的帖子

为了写到BAT文件中,方便移植。
发表于 2012-11-1 10:53:00 | 显示全部楼层
高手 ,顶起
发表于 2015-12-31 12:36:45 | 显示全部楼层
好好学习,谢谢楼主。
发表于 2016-7-2 18:02:55 | 显示全部楼层
矮油、、非常感谢楼主的分享!支持...
发表于 2025-10-7 18:52:24 | 显示全部楼层
试用了多种托盘气泡提示工具,遇到一个主要问题,连续气泡提示的情况,后续的会被吞掉,不能排队或者覆盖。

利用ai写了一个,比较耗时,不过最终结果满意,特此分享。

优点:气泡提示排队显示,基本不阻塞cmd进程。
缺点:需要安装node及依赖;CPU占用稍高;产生临时文件。

安装node
安装 依赖,命令:
  1. npm install --save node-notifier
复制代码



toast.js 代码:
  1. // toast.js
  2. const { spawn } = require("child_process");
  3. const path = require("path");
  4. const fs = require("fs");
  5. const os = require("os");

  6. const args = process.argv.slice(2);
  7. const title = args[0] || "通知标题";
  8. const message = args[1] || "这是右下角气泡通知内容";
  9. const appName = args[2] || "我的气泡通知";

  10. // 可选图标
  11. const iconPath = path.join(__dirname, "icon.png");
  12. const iconExists = fs.existsSync(iconPath);

  13. // ✅ 系统临时目录
  14. const tempDir = os.tmpdir();
  15. const uniqueId = Date.now() + "_" + Math.floor(Math.random() * 10000);
  16. const tempScript = path.join(tempDir, `_notify_${uniqueId}.js`);

  17. // ✅ 注意:这里全部使用绝对路径写入(确保在 temp 里执行)
  18. const notifierPath = require.resolve("node-notifier");

  19. // 写入子脚本
  20. fs.writeFileSync(
  21.   tempScript,
  22.   `
  23.     const notifier = require(${JSON.stringify(notifierPath)});
  24.     const path = require('path');
  25.     const fs = require('fs');

  26.     const title = ${JSON.stringify(title)};
  27.     const message = ${JSON.stringify(message)};
  28.     const appName = ${JSON.stringify(appName)};
  29.     const icon = ${iconExists ? JSON.stringify(iconPath) : "null"};

  30.     notifier.notify({
  31.       title,
  32.       message,
  33.       appName,
  34.       icon: icon ? path.resolve(icon) : undefined,
  35.       wait: false,
  36.       timeout: 3
  37.     });

  38.     setTimeout(() => {
  39.       try { fs.unlinkSync(__filename); } catch (e) {}
  40.     }, 1500);
  41.   `,
  42.   "utf8"
  43. );

  44. // ✅ 用 process.execPath 启动子进程
  45. spawn(process.execPath, [tempScript], {
  46.   detached: true,
  47.   stdio: "ignore",
  48.   shell: false,
  49. }).unref();

  50. // ✅ 主进程立即退出
  51. process.exit(0);
复制代码



cmd调用命令:
  1. node toast.js "标题" "内容" "名称(可省略)"
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 02:35 , Processed in 0.016174 second(s), 7 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表