Help with adding sound to a script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
intel339
Posts: 5
Joined: 25 Feb 2019, 20:46

Help with adding sound to a script

02 Mar 2019, 16:27

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
Rohwedder
Posts: 7627
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help with adding sound to a script

03 Mar 2019, 04:02

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
intel339
Posts: 5
Joined: 25 Feb 2019, 20:46

Re: Help with adding sound to a script

05 Mar 2019, 12:59

Perfect except what if I want this to play a different sound?

numpadsub::
number--
intel339
Posts: 5
Joined: 25 Feb 2019, 20:46

Re: Help with adding sound to a script

05 Mar 2019, 13:05

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Mannaia666 and 409 guests