Page 1 of 1

Help with adding sound to a script

Posted: 02 Mar 2019, 16:27
by intel339
Can anyone tell me what script to write in, for what I have already. I want to add a sound effect (wave file x) to trigger every time I hit the - or + keys. I want the sound to trigger one time and not multiple times - if i hit the key multiple times in a row. When I use the "wait" line - it stops the + or - from adding or subtracting more than one at a time until the sound finishes (not what I want). I just want the sound to trigger one time, and allow me to keep tapping the plus and minus key.


#persistent
number = 20
gosub, write_to_file
return

numpadadd::
number++
gosub, write_to_file
return

numpadsub::
number--
gosub, write_to_file
return

write_to_file:
file := "C:\Users\office339\Desktop\MTG files\testing counter Guest Side.txt"
filedelete, % file
fileappend, % number, % file
return

numpad9::
number = 20
gosub, write_to_file
return

Re: Help with adding sound to a script

Posted: 03 Mar 2019, 04:02
by Rohwedder
Hallo,
try:

Code: Select all

#persistent
number = 20
gosub, write_to_file
return
numpadadd::
number++
gosub, Wav
gosub, write_to_file
return
numpadsub::
number--
gosub, Wav
gosub, write_to_file
return
Wav:
IF (A_ThisHotkey <> A_PriorHotkey)
	SoundPlay, %A_WinDir%\Media\chimes.wav
Return
write_to_file:
file := "C:\Users\office339\Desktop\MTG files\testing counter Guest Side.txt"
filedelete, % file
fileappend, % number, % file
return
numpad9::
number = 20
gosub, write_to_file
return

Re: Help with adding sound to a script

Posted: 05 Mar 2019, 12:59
by intel339
Perfect except what if I want this to play a different sound?

numpadsub::
number--

Re: Help with adding sound to a script

Posted: 05 Mar 2019, 13:05
by intel339
wait I think I got it.
I made "wav2" under the subtract hotkeys

and made this:

Wav2:
IF (A_ThisHotkey <> A_PriorHotkey)
SoundPlay, C:\Users\office339\Desktop\MTG stream support files\mp3downXX.wav
Return

working so far.