Neither SoundBeep nor SoundPlay work Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RickC
Posts: 299
Joined: 27 Oct 2013, 08:32

Neither SoundBeep nor SoundPlay work

27 Apr 2022, 05:39

Dell Latitude E7450 laptop with built-in Realtek Audio, running Windows 10, AutoHotkey v1.1.33.11 and SciTE4AutoHotkey v3.0.06.01.

I tried the following examples:

Code: Select all

SoundBeep

Code: Select all

SoundBeep, 750, 500

Code: Select all

SoundPlay, %A_WinDir%\Media\ding.wav
The first two examples produce no sound at all. The third example sound like a very quick but quiet squawk... yet if I play any of the system sounds through any app (Windows Media Player, VLC, iTunes) they all play as expected.

Has anyone else experienced this and know what the problem is? (I tried updating AutoHotkey to the latest version from the previous version and tried running the AHK script manually instead of from within SciTE4AutoHotkey... still didn't work.)
User avatar
boiler
Posts: 16999
Joined: 21 Dec 2014, 02:44

Re: Neither SoundBeep nor SoundPlay work  Topic is solved

27 Apr 2022, 05:45

I don't know why SoundBeep isn't working. Windows may think your laptop has an internal system speaker while not actually having one, so it's not producing the the sound through the sound card like it would otherwise.

The reason SoundPlay isn't completing the sound is because your script ends before it completes playing. You can either use the Wait parameter:

Code: Select all

SoundPlay, %A_WinDir%\Media\ding.wav, Wait
...or do something else so that your script doesn't end immediately after executing that line.
RickC
Posts: 299
Joined: 27 Oct 2013, 08:32

Re: Neither SoundBeep nor SoundPlay work

27 Apr 2022, 05:51

Thank you, @boiler

I hadn't realised the significance of using the Wait parameter in a single-line script... but this did the trick.
NullRefEx
Posts: 2
Joined: 18 Sep 2023, 17:52

Re: Neither SoundBeep nor SoundPlay work

18 Sep 2023, 18:06

I'm necroing this because there can be a windows registry problem that causes this and the fix is extremely easy. I have no idea how this problem comes about.
The initial symptoms are SoundBeep and SoundPlay do not play sound when used in an AHK script.

The real symptom is that windows system sounds do not play. To verify this is your problem, search using the taskbar for Change System Sounds. You want the old school GUI to pop up that shows sound schemes with tabs at the top for playback and recording devices. Under the Sounds tab, select one of the sounds to test with. Use browse to ensure that file exists. Now use the test button to test the sound. If the sound doesn't play, I most likely have your solution. You're missing 1 or 2 windows registry entries. I was missing 1.

Here is the fix. Create a restore point before you mess with your registry. You will be adding keys as opposed to altering them so the risk is minimal. When it says create a REG_SZ entry, it means select "string" as the entry type.
https://www.winhelponline.com/blog/system-sounds-wav-not-playing/
NullRefEx
Posts: 2
Joined: 18 Sep 2023, 17:52

Re: Neither SoundBeep nor SoundPlay work

16 Apr 2024, 13:46

NullRefEx wrote:
18 Sep 2023, 18:06
Here is the fix. Create a restore point before you mess with your registry. You will be adding keys as opposed to altering them so the risk is minimal. When it says create a REG_SZ entry, it means select "string" as the entry type.
https://www.winhelponline.com/blog/system-sounds-wav-not-playing/
This is future me. Somehow the first registry key mentioned in the fix disappeared once again. There was a recent windows update but I'm not sure if that caused it. Once again the same fix worked. I saved myself quite a bit of time by finding myself again. However, I realize that the website might not be up forever so here are two archive links of the solution.

https://archive.is/oi4i5
https://web.archive.org/web/20230521173640/https://www.winhelponline.com/blog/system-sounds-wav-not-playing/

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: roblive, tabr3 and 406 guests