Page 1 of 1

[Solved] Sending 2 different action when a key is pressed + when it’s released

Posted: 17 Sep 2018, 12:17
by Tom1
Hello

I'm a newbie and I couldn't find code for this

I want to do this:

If MButton is being held down, do "SoundSet, 0,, Mute, 2"
and if MButton is released, do "SoundSet, 1,, Mute, 2"

How can I do that?

Thanks in advance

Re: Sending an action when a key is pressed + when a key is released

Posted: 17 Sep 2018, 12:37
by Exaskryz
MButton can be finicky, but the code should be

Code: Select all

MButton down::SoundSet, 0,, Mute, 2
MButton up::SoundSet, 1,, Mute, 2

If it doesn't work as is, try a different key instead of MButton, just to test it. Then we can come up with a different solution.

Re: Sending an action when a key is pressed + when a key is released

Posted: 17 Sep 2018, 12:54
by Tom1
Exaskryz wrote:MButton can be finicky, but the code should be

Code: Select all

MButton down::SoundSet, 0,, Mute, 2
MButton up::SoundSet, 1,, Mute, 2

If it doesn't work as is, try a different key instead of MButton, just to test it. Then we can come up with a different solution.
Thanks for your reply! Unfortunately your code doesn't work, even with a different key. "Error: Invalid hotkey."

Re: Sending an action when a key is pressed + when a key is released  Topic is solved

Posted: 17 Sep 2018, 14:53
by Exaskryz
Bah, I forgot down is not a modifier for hotkeys.

Code: Select all

MButton::SoundSet, 0,, Mute, 2
MButton up::SoundSet, 1,, Mute, 2

Re: Sending an action when a key is pressed + when a key is released

Posted: 17 Sep 2018, 20:03
by Tom1
Exaskryz wrote:Bah, I forgot down is not a modifier for hotkeys.

Code: Select all

MButton::SoundSet, 0,, Mute, 2
MButton up::SoundSet, 1,, Mute, 2
It works! Thank you very much, Exaskryz!