我用了这个代码
^+!l::
SetTitleMatchMode, 2
IfWinExist, Spotify
{
WinActivate
Send, ^l
}
else
{
Run, "C:\Users\YourUsername\AppData\Roaming\Spotify\Spotify.exe"
WinWait, Spotify
WinActivate
Send, ^l
}
return
但我不断收到错误,例如此代码包含语法错误函数调用需要空格或(仅在参数之间使用逗号
我尝试使用聊天 gpt 解决问题,但我在 v2 上不断遇到错误
#Requires AutoHotkey v2.0
^+!l::
{
if WinExist("ahk_exe Spotify.exe")
{
WinActivate
if WinWaitActive("ahk_exe Spotify.exe", , 2)
Send "^l"
}
else
{
Run "C:\Users\YourUsername\AppData\Roaming\Spotify\Spotify.exe"
if WinWait("ahk_exe Spotify.exe", , 5)
{
WinActivate
if WinWaitActive("ahk_exe Spotify.exe", , 5)
{
Sleep 2000
Send "^l"
}
}
}
}
要熟悉 AutoHotkey,请阅读初学者教程。