刚刚发现了AHK。 我有三个音频设备(扬声器,耳机,电视)
std::experimental::is_detected_convertible
无法找出AHK语法,用一个键在它们之间切换,让我们说F2。 这个小小的脚本在两个设备之间切换,但我需要在三个设备之间切换。
F2::
if (toggle := !toggle)
{
run, nircmd.exe setdefaultsounddevice "tv"
}
else
{
run, nircmd.exe setdefaultsounddevice "headphones"
}
return
所以我在考虑这样的事情,其中设备是保存音频设备名称的变量:
device = "Speakers"
F2::
if (device = "Speakers") device = "TV"
else if (device = "TV") device = "Headphones"
else if (device = "Headphones") device = "Speakers"
run, nircmd.exe setdefaultsounddevice device
return
无法将此作为有效的AHK脚本。 任何帮助表示赞赏 附: nircmd实用程序允许从命令行设置音频设备
感谢。
UPD 已更新至此,但%device%因未知原因为空。 按照手册(),应该工作,但它没有:(
https://autohotkey.com/docs/Variables.htm
UPD2 正如@Blauhim建议的那样,我在使用return语句之前有另一个键绑定。一旦我将脚本移到顶部,它就像一个魅力。感谢。
答案 0 :(得分:2)
device := "Speakers" ; alternative: device = Speakers
F2::
if (device = "Speakers")
device := "TV" ; had to be on the next line
else if (device = "TV")
device := "Headphones" ; had to be on the next line
else if (device = "Headphones")
device := "Speakers" ; had to be on the next line
run, nircmd.exe setdefaultsounddevice %device%
return