Play a sound under a specific situation
Play a sound under a specific situation
How do I make a script that plays a custom sound in this situation:
A timer starts whenever I left click. It is cancelled in 0.4 seconds or if I left click again
The timer won't get cancelled by these 2 things if I press these keys in this order: 5 > Right click > 6
After 0.5 seconds a custom sound plays and the timer ends
A timer starts whenever I left click. It is cancelled in 0.4 seconds or if I left click again
The timer won't get cancelled by these 2 things if I press these keys in this order: 5 > Right click > 6
After 0.5 seconds a custom sound plays and the timer ends
Re: Play a sound under a specific situation
Some ideas are below, may need adjusting.
Code: Select all
#InstallKeybdHook
~RButton::keep := A_PriorKey = 5
~6::keep := keep && A_PriorKey = "RButton"
~LButton::
If on := !on {
SetTimer, Reset, -400
SetTimer, Play, -500
} Else Gosub, Reset
ToolTip, %on%
Return
Play:
SoundPlay, %A_WinDir%\Media\Windows Background.wav
keep := False
Reset:
If !keep {
SetTimer, Play, Off
on := False
SoundBeep, 1000
}
ToolTip, %on%
Return
Re: Play a sound under a specific situation
@mikeyww The entire game mechanic the script is designed for goes like this: Left click (starts the script) > 5 > Right click > 6 > Right click > And then Left click > Right click x2
The thing is that the script won't work after 6. The script only checks for 5 > Right click > 6 just in case if I make a mistake after that somehow. Do you wanna make it so that the script checks for the entire mechanic except for the last right click Mikey?
The thing is that the script won't work after 6. The script only checks for 5 > Right click > 6 just in case if I make a mistake after that somehow. Do you wanna make it so that the script checks for the entire mechanic except for the last right click Mikey?
Re: Play a sound under a specific situation
You may be able to do that. One approach is to check the A_PriorKey in each case, to validate the sequence along the way. Examples are on lines 2 & 3. You may be able to extend the approach. Good luck.
Re: Play a sound under a specific situation
@mikeyww Ah that's impossible since I'm new to this and I have barely any idea what I am doing. But thank you very much for the help Mikey, I won't bother you no more
Re: Play a sound under a specific situation
I also changed the time it gets cancelled from 0.4 seconds to 0.499 seconds if that is relevant
Re: Play a sound under a specific situation
That's OK. Could be a learning opportunity at hand!