Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock sound #1

Open
Gaurav-Original-ClassicShellTester opened this issue Oct 13, 2021 · 7 comments
Open

Lock sound #1

Gaurav-Original-ClassicShellTester opened this issue Oct 13, 2021 · 7 comments

Comments

@Gaurav-Original-ClassicShellTester

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 added a commit that referenced this issue Oct 24, 2021
* Lock (e.g. Win+L or "Switch user") = Play sound of "Windows Logoff"
* Unlock = Play sound of "Windows Logon"
* Shut down/Restart/Sign out (anything that ends your session) = Play sound of "Exit Windows"
* Start the program (e.g. via startup folder or registry Run key) = Play sound of "Start Windows"

Probably satisfies #1
@shuuryou
Copy link
Owner

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:

  • Lock (e.g. Win+L or "Switch user") = Play sound of "Windows Logoff"
  • Unlock = Play sound of "Windows Logon"
  • Shut down/Restart/Sign out (anything that ends your session) = Play sound of "Exit Windows"
  • Start the program (e.g. via startup folder or registry Run key) = Play sound of "Start Windows"

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
Copy link
Author

Gaurav-Original-ClassicShellTester commented Oct 26, 2021

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:

  • Startup sound (Vista's real startup sound, but played by Sound Restore)
  • Logon sound (the startup sound played by Windows 10, replaced using Winaero Tweaker to be Vista's logon sound)
  • Log off/Exit Windows sound (played by Sound Restore)
  • Unlock sound (Windows logon sound played by Sound Restore)
    (no Lock sound) 😞

With SoundRestore 1.2 have:

  • Startup sound (I restored to the original for now since the logon sound is no longer played)
    (no Logon sound) 😞
  • Log off/Exit Windows sound (played by Sound Restore)
  • Unlock sound (Windows logon sound played by Sound Restore)
  • Lock sound (fixed)

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
Copy link
Author

Gaurav-Original-ClassicShellTester commented Oct 26, 2021

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link

ah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants