Error opening recording device

Hi, I’m trying to get Audacity (version 2.4.2) to record my Windows 10 Home x64 computer’s audio playback but I can’t get it working. Using the realtek speakers loopback, either nothing is recorded, or I get a error opening recording device: -9996 invalid device error. I’ve tried most of the suggestions on the help page, but nothing seems to be working. Thank you.

Check in the Windows Sound control panel and ensure that your realtek device is set for a sample rate of 44100 in both the Recording tab and the Playback tab.

Sorry I don’t know how you do that, I see the option to change the sample rate between 16 bit 4800 Hz and 24 bit 4800 Hz but no 44100.
Also I managed to get it everything working fine by turning off software playthrough (despite the fact I already tried that before), but the next time I opened Audacity, not working again.

I assume that you mean 48000 (not 4800).

In that case, ensure that it is set to 48000 in both the recording and playback tabs, and in Audacity preferences (“Edit menu > Preferences > Quality”) set the “Default Sample Rate” to 48000. On restarting Audacity you should see that the “Project Rate” (lower left corner of the main Audacity window) is set to 48000.

The reason for doing this is that some sound cards may fail to resample on the fly, so it is necessary to set the sample rate the same throughout.

Yes, “Software Playthrough” must be off when using loopback (it is off by default).