Help with sound script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
axo
Posts: 32
Joined: 10 May 2022, 10:50

Help with sound script

Post by axo » 30 Jun 2022, 07:05

Please help me create a script .
The script should be :

when u press a key sound1 will play but if u hold down the same key a sound2 will play but if u release the key all sounds would stop. :dance:

User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Help with sound script

Post by mikeyww » 30 Jun 2022, 07:14

How would the first sound finish if the key is always released? :roll: :?
Take it step by step; think it through. Provide a detailed example for each scenario.

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: Help with sound script

Post by axo » 30 Jun 2022, 07:32

It doesnt have to finish :D

User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Help with sound script

Post by mikeyww » 30 Jun 2022, 07:58

So you want to play 300 ms of a sound? Is it just a SoundBeep, or a MP3 or WAV file?

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: Help with sound script

Post by axo » 30 Jun 2022, 09:29

.mp3

User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Help with sound script

Post by mikeyww » 30 Jun 2022, 09:49

So the key is pressed down. What happens next? What happens after that? Please provide an example, step by step.

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: Help with sound script

Post by axo » 30 Jun 2022, 10:10

I press lbutton then sound1 will play but if I don't release the lbutton it will start playing sound2... so while a key is held down the sound2 will play ... and when i release the lbutton the sound2 will stop

User avatar
mikeyww
Posts: 26889
Joined: 09 Sep 2014, 18:38

Re: Help with sound script

Post by mikeyww » 30 Jun 2022, 10:58

Code: Select all

soundDir = d:\mwsounds
sound1   = %soundDir%\02-The_Things_We_Do_for_Love.mp3
sound2   = %soundDir%\The_Beatles_-_05_-_All_Together_Now.mp3
LButton::
SoundPlay, %sound1%
Sleep, 1000
LButton Up::SoundPlay, % GetKeyState("LButton", "P") ? sound2 : ""
Last edited by mikeyww on 30 Jun 2022, 11:13, edited 7 times in total.

axo
Posts: 32
Joined: 10 May 2022, 10:50

Re: Help with sound script

Post by axo » 30 Jun 2022, 11:02

tysm <3

Post Reply

Return to “Ask for Help (v1)”