Hello,
i downloaded two wav files that say : Activated / Deactivated
and i want to use them in a script that does the following :
when pressed a key once: it says activated
when i press the same key again: it says deactivated
then it reset the loop in a way that the 3rd press will have "activated" 4th, deactivated etc
each time i press only either one of those sounds once
can someone help me please?
Sound when pressing a key Topic is solved
Re: Sound when pressing a key
Code: Select all
dir = %A_ScriptDir%
activated = %dir%\activated.wav
deactivated = %dir%\deactivated.wav
F3::SoundPlay, % (on := !on) ? activated : deactivated
Re: Sound when pressing a key
@mikeyww I wanted to "hear" it.
Code: Select all
#SingleInstance, Force
#Warn
On := 0
F3:: ComObjCreate("SAPI.SpVoice").Speak( (On:=!On) ? "activated" : "deactivated")
Re: Sound when pressing a key
Code: Select all
ComObjCreate("SAPI.SpVoice").Speak("That is a terrific script, exclamation point.")
Re: Sound when pressing a key
wtf I didn't know you could do that!! I've been agonizing to go with a paid tts program or a free one that might be ransomware lolmikeyww wrote: ↑19 Jun 2021, 08:43Code: Select all
ComObjCreate("SAPI.SpVoice").Speak("That is a terrific script, exclamation point.")
Re: Sound when pressing a key
If I might ask a question, this is cool but it seems to hang the script. It pauses the current thread. But worse not even another hotkey can fire till it's done reading. What to do about this?mikeyww wrote: ↑19 Jun 2021, 08:43Code: Select all
ComObjCreate("SAPI.SpVoice").Speak("That is a terrific script, exclamation point.")
Re: Sound when pressing a key
Code: Select all
SpVoice := ComObjCreate("SAPI.SpVoice")
SVSFlagsAsync := SPF_ASYNC := 1 << 0
SpVoice.Speak("That is a terrific script, exclamation point.", SVSFlagsAsync)
Re: Sound when pressing a key
Nice @swagfag . Thanks!swagfag wrote: ↑19 Jun 2021, 13:08Code: Select all
SpVoice := ComObjCreate("SAPI.SpVoice") SVSFlagsAsync := SPF_ASYNC := 1 << 0 SpVoice.Speak("That is a terrific script, exclamation point.", SVSFlagsAsync)
I think I have one other question about this but I guess I should start my own thread because I've crashed this one long enough lol.
Re: Sound when pressing a key
Thanks a lot, but i already have an audio file.
all i want is ahk calling out each file at each press
all i want is ahk calling out each file at each press
Re: Sound when pressing a key
SoundPlay should be OK for you.
Re: Sound when pressing a key
yes, it's working.
this is how it looks like
Code: Select all
dir = %A_ScriptDir%
activated = C:\Users\Bae\Downloads\activated.mp3
deactivated = C:\Users\Bae\Downloads\deactivated.mp3
²::SoundPlay, % (on := !on) ? activated : deactivated
if SoundPlay, % (on := !on) ? activated :
{
RButton::
loop
{
if getkeystate("RButton", "p")
{
send, {t}
sleep, 50
send, {v}
}
else
{
break
}
}
return
}
else
{
pause
}
Last edited by riohn on 19 Jun 2021, 15:55, edited 1 time in total.
Re: Sound when pressing a key Topic is solved
Example:
Code: Select all
dir = %A_ScriptDir%
activated = C:\Users\Bae\Downloads\activated.mp3
deactivated = C:\Users\Bae\Downloads\deactivated.mp3
²::SoundPlay, % (on := !on) ? activated : deactivated
#If on
RButton::
While GetKeyState("RButton", "P") && on
{
Send t
Sleep, 50
Send v
}
Return
#If
Re: Sound when pressing a key
Thank you very much. working perfectly splendid!!
Re: Sound when pressing a key
the script dosen't work for me
Re: Sound when pressing a key
Some keyboards do not have the needed key!
Things to check:
1. Do the sound files exist?
2. Are the hotkeys being triggered?
3. What are the values of the variables & conditional statements?
Things to check:
1. Do the sound files exist?
2. Are the hotkeys being triggered?
3. What are the values of the variables & conditional statements?
Re: Sound when pressing a key
Offtopic: On this line... How to increase playback speed?mikeyww wrote: ↑19 Jun 2021, 08:43Code: Select all
ComObjCreate("SAPI.SpVoice").Speak("That is a terrific script, exclamation point.")
Re: Sound when pressing a key
thanks mikeyww
Who is online
Users browsing this forum: Google [Bot] and 127 guests