Module Windows-Shell
Windows 外壳程序
在 Windows Desktop, Windows Server, Windows Server Core 以及 Windows PE环境下
运行的轻量 Windows 外壳程序(基本桌面,开始菜单,任务栏,托盘区域,时钟区域)。
配置
| WinXShell.jcfg | 配置文件 |
| WinXShell.lua | 扩展脚本 |
WinXShell.jcfg
| JS_DESKTOP | 桌面 设置 |
| JS_THEMES | 主题 设置 |
| JS_TASKBAR | 任务栏 设置 |
| JS_STARTMENU | 开始菜单 设置 |
| JS_QUICKLAUNCH | 快速启动栏 设置 |
| JS_NOTIFYAREA | 托盘区域 设置 |
| JS_NOTIFYCLOCK | 时钟区域 设置 |
| JS_DAEMON | Daemon模式 设置 |
| JS_FILEEXPLORER | 文件资源管理器 设置 |
WinXShell.lua
| custom-script | 自定义脚本 |
菜单响应控制(系统)
| WxsHandler.SystemProperty | [此电脑] - [属性] 菜单 动作模式 |
| WxsHandler.MS_Protocols | 指定是否接管系统 ms-settings, ms-availablenetworks 协议请求处理 |
| WxsHandler.OpenContainingFolder (lnkfile, realfile) | 设置 快捷方式 的 [打开文件所在位置] 菜单的动作函数 |
事件函数(系统)
| WxsHandler.DisplayChangedHandler () | 屏幕分辨率改变事件 |
| WxsHandler.DeviceChangedHandler (event, drive) | 驱动器盘符改变事件 |
| WxsHandler.TrayClockTextFormatter () | 设置WinXShell外壳的托盘时间显示回调函数 |
事件函数(外壳)
| App:PreShell () | 外壳启动前序事件函数 |
| App:OnShell () | 外壳启动事件函数 |
| App:OnFirstShellRun () | 系统启动后,第一次外壳启动事件函数 |
| App:onDaemon () | Daemon模式启动事件函数 |
热键函数(外壳)
| Windows_S | Windows 徽标 + S 键 |
| Windows_F | Windows 徽标 + F 键 |
| CapsLockx2 | 双击大写字母锁定键(CapsLock) |
配置
WinXShell.jcfg
json 格式的配置文件,可配置外壳程序的各部分功能的显示效果。
- JS_DESKTOP
-
桌面 设置
Fields:
- 3rd_open_arguments string 双击桌面图标时,调用 第三方文件资源管理器 的参数格式
- cascademenu{'WinXNew'} string 桌面新建二级菜单
- iconsize int 桌面图标大小
- bkcolor color 桌面的背景色
- wallpaper_mode
int
壁纸显示模式 -
0- strech 拉伸 (默认) -
1- tile 平铺 -
2- center 居中
-
- wallpaper string 壁纸图片路径,不指定时使用系统壁纸
Usage:
"JS_DESKTOP": { "3rd_open_arguments": "\"%s\"", "cascademenu": { "WinXNew": "Directory\\Background\\shell\\WinXNew" }, "#iconsize": 32, "bkcolor comment": "green for eyes", "bkcolor": [199, 237, 204], "wallpaperstyle comment": "value:0-strech(default);1-tile;2-center", "::WP_MODE": 0, "wallpaper comment": "if it is not set or be empty, will use system's wallpaper image file", "::WP": "" }
- JS_THEMES
-
主题 设置
Fields:
- taskbar{'bkcolor'} color 任务栏背景色
- taskbar{'task_line_color'} color 任务图标海缆线颜色
- taskbar{'textcolor'} color 任务标题颜色
Usage:
JS_THEMES = { "blue": { "taskbar": { "bkcolor": [0, 120, 215], "task_line_color": [238, 238, 238], "textcolor": "0xffffff" } }, "dark": { "taskbar": { "bkcolor": [38, 38, 38], "task_line_color": [238, 238, 238], "textcolor": "0xffffff" } }, "light": { "taskbar": { "style": "light", "bkcolor": [238, 238, 238], "task_line_color": [0, 120, 215], "textcolor": "0x000000" } } } - JS_TASKBAR
-
任务栏 设置
Fields:
- visible bool 是否显示任务栏
- smallicon bool 是否使用小图标显示
- thumbnail bool 是否显示任务缩略图
- task_close_button bool 是否显示任务快捷关闭按钮
- no_task_title bool 是否隐藏任务标题
- userebar bool 是否使用rebar(快速启动栏)
- theme string 主题名
- height int 任务栏高度
Usage:
"JS_TASKBAR": { "visible": true, "smallicon": false, "thumbnail": true, "task_close_button": true, "no_task_title": false, "userebar": false, "theme": "dark", "height": 40 }
- JS_STARTMENU
-
开始菜单 设置
Fields:
- enabled bool 是否响应开始菜单
- start_pushed_bkcolor color 开始菜单按下状态的背景颜色
- start_icon
string
开始菜单图标 -
theme- 主题资源图标(exe文件的 ICO 资源) -
empty- 空白图标 -
custom- 自定义图标(exe文件的 ICO 资源)
-
- notopitems bool 隐藏开始菜单顶部快捷方式图标
- noprograms bool 隐藏 程序 组
- nosettings bool 隐藏 设定
- nobrowse bool 隐藏 浏览
- noconnections bool 隐藏 网络连接
- nofind bool 隐藏 查找
- norun bool 隐藏 运行
- nologoff bool 隐藏 注销
- norestart bool 隐藏 重启
- noshutdown bool 隐藏 关机
- noterm bool 隐藏 退出
- commands{'reboot'} json 自定义重启命令
- commands{'shutdown'} json 自定义关机命令
Usage:
"JS_STARTMENU": { "enabled": true, "start_pushed_bkcolor": [0, 100, 180], "start_icon_comment": "theme;empty;custom", "start_icon": "theme", "notopitems": false, "noprograms": false, "nosettings": true, "nobrowse": false, "noconnections": false, "nofind": true, "norun": false, "nologoff": true, "norestart": false, "noshutdown": false, "noterm": true, "commands": { "reboot": { "command": "Wpeutil.exe", "parameters": "Reboot" }, "shutdown": { "command": "Wpeutil.exe", "parameters": "Shutdown" } } }
- JS_QUICKLAUNCH
-
快速启动栏 设置
Fields:
- maxiconsinrow bool 快速启动栏最大单行图标个数
- 3rd_startup_arguments bool 第三方文件资源管理器打开默认参数
- hide_showdesktop bool 是否显示显示桌面图标
- hide_fileexplorer bool 是否显示文件资源管理器图标
- hide_fixedsep bool 是否隐藏系统与用户图标分割线
- hide_usericons bool 是否隐藏用户图标
- folder string 用户图标所在路径
Usage:
"JS_QUICKLAUNCH": { "maxiconsinrow": 20, "3rd_startup_arguments": "", "hide_showdesktop": false, "hide_fileexplorer": false, "hide_fixedsep": false, "hide_usericons": false, "folder": "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar" }
- JS_NOTIFYAREA
-
托盘区域 设置
Fields:
- hide_toggle_button bool 是否隐藏托盘图标折叠按钮
- hide_showdesktop_button bool 是否隐藏显示桌面按钮
- handle_system_network bool 是否接管系统原生网络图标点击事件
- handle_system_volume bool 是否接管系统原生网络图标点击事件
Usage:
"JS_NOTIFYAREA": { "hide_toggle_button": false, "hide_showdesktop_button": false, "handle_system_network": true, "handle_system_volume": true }
- JS_NOTIFYCLOCK
-
时钟区域 设置
Fields:
- visible bool 是否显示时钟区域
Usage:
JS_NOTIFYCLOCK = { "visible": true } - JS_DAEMON
-
Daemon模式 设置
Fields:
- clockarea_click json 定义时钟区域单击时调用命令
- clockarea_dbclick json 定义时钟区域双击时调用命令
- screen_brightness int 亮度
Usage:
"JS_DAEMON": { "clockarea_click": { "command": "##{JVAR_MODULEPATH}\\#{JVAR_MODULENAME}", "parameters": "-code wxsUI('UI_Calendar','main.jcfg')" }, "clockarea_dbclick": { "command": "timedate.cpl" }, "screen_brightness": 100 }
- JS_FILEEXPLORER
-
文件资源管理器 设置
Fields:
- 3rd_filename string 第三方文件资源管理器程序路径
- padding-bottom int 内置文件资源管理器(文件打开对话框)的底部高度
Usage:
JS_FILEEXPLORER = { "3rd_filename": "##{JVAR_MODULEPATH}\\explorer++.exe", "padding-bottom": 20 }
WinXShell.lua
lua 脚本配置,可编写自定义脚本,添加自定义函数,
动态变更设置,配置或重写函数控制外壳程序的各部分功能。
动态变更设置,配置或重写函数控制外壳程序的各部分功能。
菜单响应控制(系统)
- WxsHandler.SystemProperty
-
[此电脑] - [属性] 菜单 动作模式
- MODE
string
模式
auto- 自动ui_systeminfo- UI_SystemInfo 组件system- 系统属性界面空字符串('')- 不做任何处理nil- 不做任何处理
Usage:
-- 中文(Chinese): 设置 [我的电脑] - [属性] 菜单的处理方式 -- English: Configure the action for [This PC] - [Property] menu -- 'auto', 'ui_systeminfo', 'system', '' or nil WxsHandler.SystemProperty = 'auto'
- MODE
string
- WxsHandler.MS_Protocols
-
指定是否接管系统
ms-settings,ms-availablenetworks协议请求处理- CTRL
string
控制模式
none- 不接管ms-settings,ms-availablenetworks协议处理
Usage:
-- set to 'none' to disable the 'ms-settings', 'ms-availablenetworks' handlers -- WxsHandler.MS_Protocols = 'none'
- CTRL
string
- WxsHandler.OpenContainingFolder (lnkfile, realfile)
-
设置 快捷方式 的 [打开文件所在位置] 菜单的动作函数
Parameters:
Usage:
-- 中文(Chinese): 设置 快捷方式 的 [打开文件所在位置] 菜单的动作函数 -- English: Bind the function for shortcut's [OpenContainingFolder] menu WxsHandler.OpenContainingFolder = MyOpenContainingFolderHandler -- a handler of OpenContainingFolder function MyOpenContainingFolderHandler(lnkfile, realfile) -- local path = realfile:match('(.+)\\') App:Run('cmd', '/k echo ' .. realfile) -- totalcmd -- App:Run('X:\\Progra~1\\TotalCommander\\TOTALCMD64.exe', '/O /T /A \"' .. realfile .. '\"') -- XYplorer -- App:Run('X:\\Progra~1\\XYplorer\\XYplorer.exe', '/select=\"' .. realfile .. '\"') end
事件函数(系统)
- WxsHandler.DisplayChangedHandler ()
-
屏幕分辨率改变事件 屏幕分辨率发生改变后触发此事件。
Usage:
WxsHandler.DeviceChangedHandler = MyDisplayChangedHandler_AutoDPI -- 根据屏幕分辨率自动切换DPI function MyDisplayChangedHandler_AutoDPI() local cur_res_x = Screen:GetX() if last_res_x == cur_res_x then return end last_res_x = cur_res_x if last_res_x >= 3840 then Screen:DPI(150) elseif last_res_x >= 1440 then Screen:DPI(125) elseif last_res_x >= 800 then Screen:DPI(100) end end -- 屏幕分辨率发生变更后,调整桌面和任务栏 function MyDisplayChangedHandler_Adjust() Screen:Adjust() end
- WxsHandler.DeviceChangedHandler (event, drive)
-
驱动器盘符改变事件 磁盘分区挂载,卸载(USB设备插入,ISO镜像加载等)时触发此事件。
Parameters:
Usage:
WxsHandler.DeviceChangedHandler = function(event, drive) local info = string.format("Event Handled: drive=%s, event=%s", drive, event) App:Debug(info) -- Alert(info) end
- WxsHandler.TrayClockTextFormatter ()
-
设置WinXShell外壳的托盘时间显示回调函数
Usage:
-- 中文(Chinese): 设置 任务栏 时钟显示信息 -- English: Set the display text of the taskbar clock -- WxsHandler.TrayClockTextFormatter = nil if os.info('locale') == 'zh-CN' then -- WxsHandler.TrayClockTextFormatter = TrayClockTextFormatter_zhCN elseif os.info('locale') == 'en-US' then -- WxsHandler.TrayClockTextFormatter = TrayClockTextFormatter_enUS end -- 自定义时钟区域的显示信息 -- 自定义显示示例: --[[ | 22:00 星期六 | | 2019-9-14 | ]] -- FYI:https://www.lua.org/pil/22.1.html function TrayClockTextFormatter_zhCN() local wd_name = {'日', '一', '二', '三', '四', '五', '六'} local now_time = os.time() local wd_disname = ' 星期' .. wd_name[os.date('%w', now_time) + 1] local clocktext = os.date('%H:%M' .. TEXT(wd_disname) .. '\r\n%Y-%m-%d', now_time) App:SetVar('ClockText', clocktext) end -- custom tray clock display text -- sample for: --[[ | 22:00 Sat | | 2019-9-14 | ]] -- FYI:https://www.lua.org/pil/22.1.html function TrayClockTextFormatter_enUS() local now_time = os.time() local clocktext = os.date('%H:%M %a\r\n%Y-%m-%d', now_time) App:SetVar('ClockText', clocktext) end
事件函数(外壳)
- App:PreShell ()
- 外壳启动前序事件函数
- App:OnShell ()
- 外壳启动事件函数
- App:OnFirstShellRun ()
- 系统启动后,第一次外壳启动事件函数
- App:onDaemon ()
- Daemon模式启动事件函数
热键函数(外壳)
- Windows_S
-
Windows 徽标 + S 键
Usage:
Shell.onHotKey['WIN+S'] = function() App:Debug("WIN+S hotkey is pressed.") end
- Windows_F
-
Windows 徽标 + F 键
Usage:
Shell.onHotKey['WIN+F'] = function() App:Debug("WIN+F hotkey is pressed.") end
- CapsLockx2
-
双击大写字母锁定键(CapsLock)
Usage:
Shell.onHotKey['CAPSLOCK x 2'] = function() App:Debug("CAPSLOCK x 2 pressed.") end