How to add a on and off sound to a toggle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Tymoru
Posts: 2
Joined: 12 Sep 2020, 22:43

How to add a on and off sound to a toggle

13 Sep 2020, 12:51

I would like to add an alert of sorts using sound for when I toggle (F1) my code on and off. I have tried adding a soundbeep with the same hotkey, but that doesn't work. I have tied simply adding a SoundBeep to my code. However it only worked when I pressed LButton, when I wanted it to work when I presses F1. I have tied some other stuff but to no avail. Any help would be greatly appreciated. (P.S. My code is meant to click right mouse button right after I click the left mouse button with a random delay.)

(Here is my code)

Code: Select all

F1::Hotkey, LButton, Toggle

LButton::
SendInput {LButton}
Random, SleepAmount, 92, 117
Sleep, %SleepAmount%
SendInput {RButton}
return

F10::ExitApp
User avatar
mikeyww
Posts: 27095
Joined: 09 Sep 2014, 18:38

Re: How to add a on and off sound to a toggle

13 Sep 2020, 13:46

Code: Select all

F1::
Hotkey, LButton, Toggle
toggle := !toggle
SoundBeep, % toggle ? 1500 : 1000, 20
Return
Tymoru
Posts: 2
Joined: 12 Sep 2020, 22:43

Re: How to add a on and off sound to a toggle

13 Sep 2020, 20:00

mikeyww wrote:
13 Sep 2020, 13:46

Code: Select all

F1::
Hotkey, LButton, Toggle
toggle := !toggle
SoundBeep, % toggle ? 1500 : 1000, 20
Return
Thank you for your help and I just want to know, will this work with SoundPlay by chance (If yes would I just replace the SoundBeep or is it some other way)? Or will that require different code?
User avatar
mikeyww
Posts: 27095
Joined: 09 Sep 2014, 18:38

Re: How to add a on and off sound to a toggle

14 Sep 2020, 06:14

You can try it and see, right?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder, sanmaodo and 137 guests