如何将CTRL+ALT+X映射为CTRL+ALT+M以触发邮件弹窗?
解决Ctrl+Alt+X映射为Ctrl+Alt+M触发邮件弹窗的问题
问题背景
日常工作中需在某平台发送大量邮件,该平台默认触发邮件弹窗的快捷键为CTRL+ALT+M,但单手操作时按键M不易触及,希望将CTRL+ALT+X映射为CTRL+ALT+M,但网站无修改快捷键选项,尝试Chrome的Shortcuts扩展及对应配置无效。
可行解决方案
1. 修正Chrome Shortcuts扩展配置
你之前的配置未指定目标网站域名,导致扩展无法在对应站点生效,修改配置如下:
{ "key": "ctrl+alt+x", "action": "trigger", "trigger": "ctrl+alt+m", "sites": "*://your-target-site.com/*", "sitesArray": [ "*://your-target-site.com/*" ] }
- 替换
your-target-site.com为目标平台的实际域名 - 进入Chrome扩展管理页面,确保Shortcuts扩展已获得该网站的访问权限
- 保存配置后刷新目标平台页面测试
2. 使用Tampermonkey油猴脚本
通过用户脚本直接在页面内监听并模拟按键行为,兼容性更强:
// ==UserScript== // @name 快捷键映射:Ctrl+Alt+X → Ctrl+Alt+M // @namespace http://tampermonkey.net/ // @version 0.1 // @description 将Ctrl+Alt+X映射为Ctrl+Alt+M触发邮件弹窗 // @match *://your-target-site.com/* // @grant none // ==/UserScript== (function() { 'use strict'; document.addEventListener('keydown', function(e) { if (e.ctrlKey && e.altKey && e.key.toLowerCase() === 'x') { e.preventDefault(); // 模拟Ctrl+Alt+M按下事件 const downEvent = new KeyboardEvent('keydown', { ctrlKey: true, altKey: true, key: 'M', code: 'KeyM', bubbles: true, cancelable: true }); document.dispatchEvent(downEvent); // 模拟按键抬起事件 setTimeout(() => { const upEvent = new KeyboardEvent('keyup', { ctrlKey: true, altKey: true, key: 'M', code: 'KeyM', bubbles: true, cancelable: true }); document.dispatchEvent(upEvent); }, 50); } }); })();
- 修改
@match字段为目标平台的域名 - 将脚本导入Tampermonkey后,刷新目标页面即可生效
3. Windows系统用AutoHotkey全局映射
如果需要跨浏览器或全局生效,可使用AutoHotkey:
; 仅在Chrome激活时生效(避免干扰其他程序) #IfWinActive, ahk_exe chrome.exe ^!x::Send ^!m #IfWinActive
- 安装AutoHotkey后,将上述代码保存为
.ahk文件并运行 - 若无需限定Chrome,直接写
^!x::Send ^!m即可实现全局映射
内容的提问来源于stack exchange,提问作者Jonas Naucius
相关产品推荐
相关产品推荐

