将两个脚本合并为一个脚本失败

将两个脚本合并为一个脚本失败

作为两个独立的脚本,热键可以正常工作。合并到一个文件中后,#^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

相关内容