引自免费微信小程序:皆我百晓生
看起来你在尝试使用AutoHotkey脚本来控制Chrome浏览器和微信。根据你的描述,^w 和 +w 的热键似乎没有按预期工作。在AutoHotkey中,^ 代表 Control 键,+ 代表 Shift 键。你的代码中可能存在一些小错误,导致这两个热键无法正确触发。
下面是修正后的代码,主要是在检查微信窗口是否存在时使用了精确匹配模式("TitleMatchMode, RegEx"`),并确保了对Control和Shift键的正确处理:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; 设置标题匹配为正则表达式模式
TitleMatchMode, RegEx
!l::
if WinExist("ahk_class Chrome_WidgetWin_1")
WinActivate
else
Run("chrome.exe")
return
^l::
if WinExist("ahk_class Chrome_WidgetWin_1")
WinMinimize
return
+l::
if WinExist("ahk_class Chrome_WidgetWin_1")
WinClose
return
!w::
IfWinExist("WeChatMainWndForPC", "微信")
WinActivate()
else
Run("C:\Program Files\Tencent\WeChat\WeChat.exe")
return
^w::
IfWinExist("WeChatMainWndForPC", "微信")
WinMinimize
return
+w::
IfWinExist("WeChatMainWndForPC", "微信")
WinClose
return
return
这段代码应该可以正确地实现你想要的功能。如果你仍然遇到问题,请确认微信的窗口标题是否确实为 "WeChatMainWndForPC",并且路径 "C:\Program Files\Tencent\WeChat\WeChat.exe" 是正确的。如果微信的窗口标题有变化或者安装位置不同,你需要相应地调整这部分内容。
另外,如果你发现某些按键组合不起作用,可能是由于其他软件也使用了相同的快捷键。在这种情况下,你可以尝试更改快捷键或者禁用冲突程序的热键。