简体   繁体   English

一个热键上的多种功能(键按住和释放)

[英]Multiple functions on one hotkey (key hold down and release)

I'm trying to build script which lowers volume once when hotkey is held down and after key is released volume is set back to normal/previous volume.我正在尝试构建脚本,该脚本在按住热键并释放键后将音量设置回正常/以前的音量时降低一次音量。 This same key (when hold down) should also send input like normal key.这个相同的键(按住时)也应该像普通键一样发送输入。

Case:案子:

  • Hold down w -key volume is lowered only once and w is sent multiple times (like normal key hold)按住w -key 音量只降低一次,并且 w 被多次发送(就像正常的按键保持一样)
  • Release w -key volume is set back to normal释放w -key 音量设置恢复正常

Here is my current script which works for volume as described:这是我当前的脚本,它适用于所描述的音量:

$w::
SoundGet OldVolume
SoundSet, -20
KeyWait, w
w UP::SoundSet OldVolume
return

I did try to make loop to send w when hold down but then volume adjustment did not work anymore.我确实尝试在按住时循环发送w但音量调节不再起作用。

I'm not sure if this multiaction is even possible where key press should do something only once and something else multiple times.我不确定在按键应该只做一次而其他事情多次的情况下,这种多动作是否可行。 Any help appreciated!任何帮助表示赞赏!

You'll be fine with just specifying the ~ hotkey modifier.只需指定~热键修饰符就可以了。
It's going to make the hotkey not consume the key when used.这将使热键在使用时不会消耗密钥。 So the key will retain its normal functionality as well.因此,密钥也将保留其正常功能。

And also, you don't need the w UP hotkey variant, just set the old sound level under the KeyWait command.而且,您不需要w UP热键变体,只需在KeyWait命令下设置旧的音量即可。

Here's your complete script:这是您的完整脚本:

~w::
    SoundGet, OldVolume
    SoundSet, -20
    KeyWait, w
    SoundSet, OldVolume
return

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM