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

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Tom1
Posts: 24
Joined: 17 Sep 2018, 12:05
Contact:

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

17 Sep 2018, 12:17

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
Last edited by Tom1 on 17 Sep 2018, 20:25, edited 2 times in total.
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

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

17 Sep 2018, 12:37

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.
User avatar
Tom1
Posts: 24
Joined: 17 Sep 2018, 12:05
Contact:

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

17 Sep 2018, 12:54

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."
User avatar
Exaskryz
Posts: 2876
Joined: 17 Oct 2015, 20:28

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

17 Sep 2018, 14:53

Bah, I forgot down is not a modifier for hotkeys.

Code: Select all

MButton::SoundSet, 0,, Mute, 2
MButton up::SoundSet, 1,, Mute, 2
User avatar
Tom1
Posts: 24
Joined: 17 Sep 2018, 12:05
Contact:

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

17 Sep 2018, 20:03

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!

Return to “Ask For Help”

Who is online

Users browsing this forum: DRocks, johnqflorida, kczx3 and 56 guests