![将两个脚本合并为一个脚本失败](https://linux22.com/image/1574149/%E5%B0%86%E4%B8%A4%E4%B8%AA%E8%84%9A%E6%9C%AC%E5%90%88%E5%B9%B6%E4%B8%BA%E4%B8%80%E4%B8%AA%E8%84%9A%E6%9C%AC%E5%A4%B1%E8%B4%A5.png)
作为两个独立的脚本,热键可以正常工作。合并到一个文件中后,#^l 和 #^h 热键停止工作。这是故障还是我做错了什么?
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey
releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LAlt::LWin
LWin::LAlt
CapsLock::LCtrl
#^l::#^Right
#^h::#^Left
答案1
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
LAlt::LWin
LWin::LAlt
CapsLock::LCtrl
; LAlt+CapsLock+l ; switch to next virtual desktop
#^l:: SendEvent {LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up}
; LAlt+CapsLock+h ; switch to previous virtual desktop
#^h:: SendEvent {LWin down}{LCtrl down}{Left down}{LWin up}{LCtrl up}{Left up}
https://autohotkey.com/docs/commands/Send.htm#SendEvent
在Win10上测试。
答案2
尝试这个 :
LAlt::
Send, {LWin down}
Send, {LWin up}
return
LWin::
Send, {Alt down}
Send, {Alt up}
return