自动热键.按住两个按钮并轻按另一个以增加音量 [英] Autohotkey. Hold two buttons and tap another to increase volume

查看:68
本文介绍了自动热键.按住两个按钮并轻按另一个以增加音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法构建ahk快捷脚本来增加/减少音量.这个想法是按住LAlt + LShift并轻按F12可以使每个轻击增加一级. 按下LAlt和LShift的顺序无关紧要.

I got stuck building an ahk shortcut script to increase / decrease Volume. The idea was to hold down LAlt+LShift and tap F12 to increase one step per tap. The order in which LAlt and LShift are pressed shouldn't matter.

到目前为止,我想到了这一点:

I came up with this so far:

!+::
    While (GetKeyState("LShift","P")) and (GetKeyState("LAlt","P"))
    {
        F12::Send {Volume_Up}
    }
Return

但是以某种方式增加了保持LAlt和编带F12的音量. LShift变得不可思议了..

But somehow it increases the volume on holding LAlt and taping F12. LShift gets igronred..

那是怎么回事...

推荐答案

    F12::Send {Volume_Up}

不是命令,而是热键分配.您不能在可执行上下文中使用它.它实际上是以下内容的缩写形式:

isn't a command, it's a hotkey assignment. You cannot use it within executable context. It is actually the short form for:

F12::
send {volume_up}
return

您不想在应该执行的两行之间有一个return.

You wouldn't wanna have a return somewhere in between the lines which should be executed, would you.

正如在文档中可以读到的那样,您只能将两个热键组合在一起才能轻松执行某项操作,例如a & b::msgbox, you pressed a and b.例如.对于 a b c ,您需要一些变通方法,例如以下划掉的旧答案.

As can be read in the documentation, you can only combine two Hotkeys for an action easily, like a & b::msgbox, you pressed a and b. E.g. for a,b AND c, you'd need some workaround like the crossed out, old answer below.

但是,您可以根据需要在热键中添加任意数量的修饰符.修饰符是! alt + shift # win 等(请看一下@ http://ahkscript.org/docs/Hotkeys.htm#Symbols ).

BUT you can add as many modifiers to your hotkey as you want. Modifiers are ! alt, + shift, # win and so on (please have a look @ http://ahkscript.org/docs/Hotkeys.htm#Symbols).

所以您可以简单地使用

<!+F12::send {volume_up}

-

因此,您的目标只是在按下三个热键时触发volume_up.您可以这样实现:

So, your aim is simply to have volume_up be fired when three Hotkeys are being pressed. You can achieve it like this:

#if getKeyState("LShift", "P")
    *<!F12::send {volume_up}
#if

*<!F12::
    if(getKeyState("LShift","P"))
        send {volume_up}
return

有关*<以及其他可能的修饰符的含义,请参见 http://ahkscript.org/docs/Hotkeys.htm#Symbols

For the meaning of * and < and other possible modifiers, see http://ahkscript.org/docs/Hotkeys.htm#Symbols

您的方法还不错.如果您使用了热键命令而不是实际的热键分配,那将会奏效.仍然是不需要的工作

Your approach wasn't too bad. It would have worked if you had used the Hotkey command instead of an actual hotkey assignment. Still that would have been unneeded work

这篇关于自动热键.按住两个按钮并轻按另一个以增加音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆