shuuryou / soundrestore

Restores the logon, logoff, and unlock sound events in Windows 10
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Lock sound #1

Open Gaurav-Original-ClassicShellTester opened 3 years ago

Gaurav-Original-ClassicShellTester commented 3 years ago

Firstly, thank you and great work! The sounds for Logoff/Exit Windows, Unlock and Logon work perfectly.

Is it possible to also have a Lock sound after pressing Win+L or Start menu -> Lock? Windows XP and Windows Vista and 7 used to have one.

shuuryou commented 3 years ago

Hello

Sorry for the late reply. GitHub messages goes to my trash email account and I only check it rarely.

Technically it is no problem. The reason I didn't include it was that I found nothing suitable in HKEY_CURRENT_USER\AppEvents\EventLabels and didn't know better at the time. This was one of those programs I made quickly when Microsoft decisions once again managed to piss me off just enough. Thanks, @oldnewthing ...

I built an update and put it on the Release. Please try it if you want. It works as follows now:

This seems to make the most sense especially when using classic desktop themes, e.g. I log off my session so my friend can use the computer, then I want to hear my shutdown sound. I think this is also how Windows 98 did it.

How to upgrade:

  1. First you should probably unset your custom sounds via the Control Panel (at least for "Windows Unlock" since it will disappear again next)
  2. Use HideSoundEvents.reg from the old release to put everything to default state
  3. Kill the soundrestore.exe process via Task Manager or command line: taskkill /f /im soundrestore.exe
  4. Apply the updated RestoreSoundEvents.reg
  5. Replace the EXE file with the updated release
  6. Set sounds "Windows Logoff", "Windows Logon", "Exit Windows" and "Start Windows" as you like via Control Panel
  7. Start soundrestore.exe manually once.

I hope it works as you wish afterwards.

I tested with Windows 10.0.19041.804. I can't run Windows Update because it causes a boot-loop and I had to restore my PC from backup, so I gave up and just disabled Windows Update and its hostile auto-repair shit completely.

Gaurav-Original-ClassicShellTester commented 3 years ago

Ah finally I had the time to try it. Yes this is awesome and now brings back the Lock and Unlock sounds as before.

However in this version, now there is no sound played for logon (after logging off) which it did in the earlier version.

What I had done was a trick using Winaero Tweaker to set the startup sound to "Windows Logon Sound.wav" from Vista/7. I load SoundRestore.exe very early at startup using the Taskman reg value: https://www.geoffchappell.com/notes/windows/shell/explorer/taskman.htm

Then I set the logon sound to the one Windows Vista/7 played as the startup sound. The net result was that because Taskman loaded Soundrestore very early on before it logged on, on Windows 10, the original startup sound played exactly like Windows Vista (by SoundRestore), then the logon sound of Vista played (by Windows).

The log off sound shared with Exit Windows is ok. And I had the distinct Lock/Unlock sounds too.

So now here's the situation:

With SoundRestore 1.1, I had:

With SoundRestore 1.2 have:

Can you produce a version where all 5 sound events play, please? 🙂

With 1.1, I had modified the reg as follows:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\AppEvents\EventLabels\WindowsLogon]
"ExcludeFromCPL"=dword:00000000
[HKEY_CURRENT_USER\AppEvents\EventLabels\WindowsLogoff]
"ExcludeFromCPL"=dword:00000000
[HKEY_CURRENT_USER\AppEvents\EventLabels\WindowsUnlock]
"ExcludeFromCPL"=dword:00000000

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogoff\.Current]
@="C:\\Windows\\media\\Windows Shutdown.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogoff\.Default]
@="C:\\Windows\\media\\Windows Shutdown.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogoff\.Modified]
@="C:\\Windows\\media\\Windows Shutdown.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogon\.Current]
@="C:\\Windows\\media\\Windows Startup Sound.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogon\.Default]
@="C:\\Windows\\media\\Windows Startup Sound.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsLogon\.Modified]
@="C:\\Windows\\media\\Windows Startup Sound.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsUnlock\.Current]
@="C:\\Windows\\media\\Windows Logon sound.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsUnlock\.Default]
@="C:\\Windows\\media\\Windows Logon sound.wav"

[HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\WindowsUnlock\.Modified]
@="C:\\Windows\\media\\Windows Logon sound.wav"
Gaurav-Original-ClassicShellTester commented 3 years ago

Well problem solved. For now, I have added SoundRestore 1.2 to load later at startup and for Taskman, I play a VBScript:

WScript "Logon sound.vbs"

Here's what Logon sound.vbs contains:

Set oVoice = CreateObject("SAPI.SpVoice")
set oSpFileStream = CreateObject("SAPI.SpFileStream")
oSpFileStream.Open "C:\Windows\Media\Windows logon sound.wav"
oVoice.SpeakStream oSpFileStream
oSpFileStream.Close
shuuryou commented 3 years ago

That VBS workaround is probably the most sensible approach since it lets you use v1.2 as it was intended to be used. I had no idea about the Taskman registry key so thanks for showing me that.

Problem right now is that I have no way to compile the code at the moment because Windows Update of all things killed my separate work PC with Visual Studio. I have at this point resigned to using Linux as my work OS and just running Windows in a VM so I can revert to whatever the last snapshot was when it decides to randomly break again.

I might experiment later when I get up and running again to see if I can come up with something more useful.

TorutheRedFox commented 1 month ago

sorry for the necropost but locking and unlocking sounds are done by listening to WM_WTSSESSION_CHANGE and playing WindowsLogoff on WTS_SESSION_LOCK and WindowsLogon on WTS_SESSION_UNLOCK (set in wParam)

this is the way Windows itself did it from Windows XP up until 8.1

shuuryou commented 4 weeks ago

If I understand your comment correctly, that is what the app is doing at the moment.

https://github.com/shuuryou/soundrestore/blob/main/src/soundrestore/DummyForm.cs#L94

private void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
    if (e.Reason == SessionSwitchReason.SessionUnlock)
        Play(Sound.Logon);
    else if (e.Reason == SessionSwitchReason.SessionLock)
        Play(Sound.Logoff);
    // Weird because user expects shutdown sound when session ends
    //else if (e.Reason == SessionSwitchReason.SessionLogoff)
    //  Play(Sound.Logoff); 
    // Cannot work since this program is not running when it would fire
    //else if (e.Reason == SessionSwitchReason.SessionLogon)
    //  Play(Sound.Logon);
}
TorutheRedFox commented 4 weeks ago

ah