SoundPlay Question

Ask gaming related questions (AHK v1.1 and older)
todd_k
Posts: 1
Joined: 26 May 2020, 09:43

SoundPlay Question

19 Jun 2021, 02:30

Hi. I've been using autohotkey to toggle auto pressing in games with this script and I'm trying to add SoundPlay command but has been unsuccessful. The goals are to (1) play 2 different sounds when toggle on and off or (2) play a sound continuously until toggle off. Any help to get them to work would be appreciated. Thank you.

Code: Select all

1::
RepeatKey := !RepeatKey
If RepeatKey
	SetTimer, SendTheKey, 2000
Else
	SetTimer, SendTheKey, Off
Return
SendTheKey:
SendInput {Numpad1}
SendInput {Numpad2}
SendInput {Numpad3}
SendInput {Numpad4}
SendInput {Numpad5}
Return
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: SoundPlay Question

19 Jun 2021, 04:58

Can you show your script with SoundPlay included that you say was unsuccessful and describe what “unsuccessful” was? Did it not play anything? Did it not play it at the right time?

Try this:

Code: Select all

1::
RepeatKey := !RepeatKey
SoundPlay, % RepeatKey ? "PathToSound1.wav" : "PathToSound2.wav"
If RepeatKey
	SetTimer, SendTheKey, 2000
Else
	SetTimer, SendTheKey, Off
Return

SendTheKey:
loop, 5
	SendInput {Numpad%A_Index%}
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: aaa666 and 42 guests