{"id":17998439,"url":"https://github.com/kosaka-bun/tray-icon-runner","last_synced_at":"2025-04-07T06:11:19.931Z","repository":{"id":152663756,"uuid":"583085406","full_name":"kosaka-bun/tray-icon-runner","owner":"kosaka-bun","description":"为运行的程序添加托盘图标的工具","archived":false,"fork":false,"pushed_at":"2025-01-18T17:52:01.000Z","size":106,"stargazers_count":107,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T05:05:03.354Z","etag":null,"topics":["c-sharp","desktop","system-tray","tray-icon","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kosaka-bun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-28T18:09:33.000Z","updated_at":"2025-02-24T05:35:59.000Z","dependencies_parsed_at":"2025-01-18T18:39:31.031Z","dependency_job_id":"6a37745a-6635-4e83-900d-7ab30288b97e","html_url":"https://github.com/kosaka-bun/tray-icon-runner","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosaka-bun%2Ftray-icon-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosaka-bun%2Ftray-icon-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosaka-bun%2Ftray-icon-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kosaka-bun%2Ftray-icon-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kosaka-bun","download_url":"https://codeload.github.com/kosaka-bun/tray-icon-runner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","desktop","system-tray","tray-icon","windows"],"created_at":"2024-10-29T21:25:21.051Z","updated_at":"2025-04-07T06:11:19.901Z","avatar_url":"https://github.com/kosaka-bun.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrayIconRunner\n\n![DotNet](https://img.shields.io/badge/.Net%20Framework-4.7.2-brightgreen?logo=dotnet)\n[![License](https://img.shields.io/github/license/kosaka-bun/tray-icon-runner?label=License\u0026color=blue\u0026logo=GitHub)](./LICENSE)\n![GitHub Stars](https://img.shields.io/github/stars/kosaka-bun/tray-icon-runner?label=Stars\u0026logo=GitHub\u0026style=flat)\n[![Release](https://img.shields.io/github/release/kosaka-bun/tray-icon-runner?label=Release\u0026logo=GitHub)](../../releases)\n\n## 简介\n一款可将任何桌面程序的主窗口最小化到托盘区域的工具，其主要原理是先创建托盘图标，然后通过Win32 API来Hook一个进程的窗口事件，并在进程的主窗口被最小化时，隐藏主窗口。当托盘图标被点击时，再重新显示其窗口。\n\n本项目采用GPL-3.0 License，其要求：\n\n- 本项目的衍生项目需采用GPL-3.0 License。\n- 必须在修改的文件中附有明确的说明，须包含所修改的部分及具体的修改日期。\n- 通过任何形式发布衍生项目的可执行程序时，必须同时附带或公布衍生项目的源代码。\n\n请参阅：[更新日志](./docs/changelog.md)\n\n## 用法\n以Elastic Search为例，Elastic Search是通过脚本启动的，启动后会持续保留一个控制台窗口，不便使用。\n\n首先[下载](../../releases/latest)TrayIconRunner的可执行程序，并将其解压到一个目录中。\n\n在Elastic Search的启动脚本所在的目录，即`{Elastic Search安装目录}/bin`目录下，创建一个名为`startup.tir`的文件，在其中输入以下内容并保存。\n\n```json\n{\n  \"file\": \"elasticsearch.bat\",\n  \"name\": \"Elastic Search\"\n}\n```\n\n右键`startup.tir`文件，设置其属性，将打开方式更改为TrayIconRunner。\n\n![](./docs/img/1.png)\n\n双击打开`startup.tir`，可以看到`elasticsearch.bat`已经被执行，且托盘区域已出现对应的图标。\n\n![](./docs/img/2.png)\n\n点击控制台窗口上的最小化按钮，可以看到控制台窗口已被隐藏，任务栏上已没有此控制台窗口的项目。\n\n点击托盘区域的图标，可以看到控制台窗口已恢复显示。\n\n停止Elastic Search的运行脚本，可以看到托盘区域的图标已消失，TrayIconRunner的进程也已结束。\n\n## `.tir`文件\n`.tir`文件为JSON格式，但也可以为空文件。\n\n假设某目录下有一个`test.exe`文件，则我们可以在该目录下创建一个名为`test.tir`的空文件，双击打开它时，TrayIconRunner将会打开与`.tir`文件在同一个目录下的、同名的`.exe`文件，并为其创建托盘图标。\n\n如果您不想让TrayIconRunner根据文件的扩展名自动查找要打开的程序，可以在`.tir`文件中，手动指定要用来打开文件的可执行程序。\n\n```json\n{\n  \"file\": \"Virtual Machine.vmx\",\n  \"name\": \"Virtual Machine\",\n  \"executor\": \"C:\\\\Program Files (x86)\\\\VMware\\\\VMware Workstation\\\\vmplayer.exe\"\n}\n```\n\n上例当中，我们添加了一个key为`executor`的键值对，其中指定了要用来打开`Virtual Machine.vmx`的可执行程序，TrayIconRunner将使用它。需要注意的是，`executor`键对应的值（路径）当中的反斜杠，必须按照JSON规范进行转义。\n\n如果`.tir`文件中不包含key为`executor`的键值对，则TrayIconRunner将自动根据key为`file`的键值对中的文件扩展名，寻找要用来打开这个文件的可执行程序。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosaka-bun%2Ftray-icon-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkosaka-bun%2Ftray-icon-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkosaka-bun%2Ftray-icon-runner/lists"}