Help with sound (simple noob script)

Ask gaming related questions (AHK v1.1 and older)
Expose96
Posts: 30
Joined: 02 Mar 2017, 13:50

Help with sound (simple noob script)

20 Feb 2018, 09:30

Hi! :wave: Im rying to make a sound play when my toggle is on and off. any help would be appreciated :thumbup: would it also be possible using sounplay instead of soundbeep?

Code: Select all

tog:=0

SoundPlay, %A_ScriptDir%\Sounds\scriptactiver.mp3

if GetKeyState(key_Terminate)
{
SoundPlay, %A_ScriptDir%\Sounds\scriptdesactiver.mp3
sleep 4000
ExitApp
}

x::tog:=!tog

#If (tog)
Suspend, Toggle
SoundBeep, 800, 100
return

~$LButton::
While GetKeyState("LButton", "P"){
MouseClick ,Left,X,Y,3,0
Send {"}
Sleep 550
KeyWait, LButton, D
MouseClick ,Left,X,Y,3,0
Send {'}
Sleep 550
}
return

#If
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Help with sound (simple noob script)

21 Feb 2018, 02:11

Hi..
try this :

Code: Select all

x::
Suspend, permit
if (State = 0) ; Checks the current state of variable "State". And if it is False (zero)...
{
   SoundPlay *48 ; Plays a system sound...
   State++ ; And changes the value of variable "State" to True (one)
}
Else ; Otherwise...
{
   State := 0 ; Sets the value of State variable to False (zero)...
   SoundPlay *16 ; And plays another system sound.
}
Suspend, Toggle ; In both cases suspend is toggled, but due to the overall logic of the routine, it is toggled to On whenever State was zero and off whenever it was one.
Return


~$LButton::
While GetKeyState("LButton", "P"){
Click, Left, 3
Send {"}
Sleep 550
KeyWait, LButton, D
Click, Left, 3
Send {'}
Sleep 550
}
return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 73 guests