thinkpads.com Support Community Forum Index Bill Morrow's thinkpads.com Open Forum - The Original Thinkpad Support Forum
Follow ThinkpadsForum on Twitter
 Support this forum, shop at newmodeus.com
 Support the forum, shop at newmodeus.com
 The thinkpads support forum is now hosting legacy model ThinkPad driver and driver updates..
A link is provided in the MENUBAR just above for registered forum members only..

If you so wish:
Donate using PayPal

It is currently Tue Oct 21, 2014 12:21 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 04, 2010 10:53 am 
Offline
Junior Member
Junior Member

Joined: Tue Feb 14, 2006 2:17 pm
Posts: 438
Location: Bucks., UK
From reading Problems with non-thinkpad option drives on T43 thinkpads in the T4x forum, I believe a fair few users would appreciate a solution to this seemingly trivial problem.

As most are aware replacing the hard disc with a non-IBM disc, produces an error message and two beeps at boot time. With a BIOS setting, you can automatically skip on from the error message after 3 seconds, but that does not suppress the beeps.

I have been thinking about this and if you mute the sound when you power down, you do not get the beeps on power up. So…..

I started off with a small application called nircmd.exe, but my thanks to RealBlackStuff who posted the warning to rename nircmd.exe to another name, as it can be used maliciously. The solution below does not require nircmd.exe.

I then discovered that the ‘wheel had already been invented’ –well nearly. I found a solution that turns of the sound entering hibernation or sleep (-actually, I don’t think it is necessary for sleep) and then turns it back on when resuming. The code uses a free application called autohotkey at http://www.autohotkey.com and the code itself was written by Dirk Schwarzmann and was posted in a topic 'Running commands on standby, hibernation and resume events' at http://www.autohotkey.com/forum/topic21697.html

Dirk Schwarzmann’s code is:
Code:
/*
   Mute on hibernation
   
   Purpose:
      Mute the internal speakers if the computer is sent into hibernation or standby mode.
       
      Some laptop models of Fujitsu-Siemens are making short beep sounds everytime
      they are sent into sleep mode. This annoying behavior cannot be switched off,
      so this program circumvents it by disabling the speakers before sleep mode and
      reactivating them when resuming from hibernation.
   
   Functioning:
      The program runs in background, listening for the system´s message to hibernate
      the computer. It then mutes the speakers and turns them on again after the
      computer woke up.
      The mute state is left untouched in case the speakers were not muted by this
      program.
      The program will create one registry entry to save the mute state.
   
   Requirements:
      - Windows 2000 and newer
      - Read and write permission to HKEY_CURRENT_USER registry stem.
       
   
   Author:  Dirk Schwarzmann
   Version: 0.2
   Date:    2007-08-02
   
   Contact:
      Dirk 'Rob' Schwarzmann
      http://www.dirk-schwarzmann.de
      mailto://dirk@dirk-schwarzmann.de
   
   Version history:
      0.1, 2007-08-01: Initial version
      0.2, 2007-08-02: Replace unreliable timer function by real power event parameters
*/

; Registry location to save the mute state
reg_root = HKEY_CURRENT_USER
reg_path = SessionInformation
reg_key  = MutedforSuspend

; Tray icon and menu definition
Menu, TRAY, Icon, MuteOnHibernate.ico, 1, 1
Menu, TRAY, Tip, Mute speakers on hibernation

; Listen to the Windows power event "WM_POWERBROADCAST" (ID: 0x218):
OnMessage(0x218, "func_WM_POWERBROADCAST")
Return

/*
   This function is executed if the system sends a power event.
   Parameters wParam and lParam define the type of event:
   
   lParam: always 0
   wParam:
      PBT_APMQUERYSUSPEND             0x0000
      PBT_APMQUERYSTANDBY             0x0001
       
      PBT_APMQUERYSUSPENDFAILED       0x0002
      PBT_APMQUERYSTANDBYFAILED       0x0003
       
      PBT_APMSUSPEND                  0x0004
      PBT_APMSTANDBY                  0x0005
       
      PBT_APMRESUMECRITICAL           0x0006
      PBT_APMRESUMESUSPEND            0x0007
      PBT_APMRESUMESTANDBY            0x0008
       
      PBTF_APMRESUMEFROMFAILURE       0x00000001
       
      PBT_APMBATTERYLOW               0x0009
      PBT_APMPOWERSTATUSCHANGE        0x000A
       
      PBT_APMOEMEVENT                 0x000B
      PBT_APMRESUMEAUTOMATIC          0x0012
       
      Source: http://weblogs.asp.net/ralfw/archive/2003/09/09/26908.aspx
*/
func_WM_POWERBROADCAST(wParam, lParam)
{
   Global reg_root, reg_path, reg_key
   
   If (lParam = 0) {
      ; PBT_APMSUSPEND or PBT_APMSTANDBY? -> System will sleep
      If (wParam = 4 OR wParam = 5) {
         ; Get mute state
         SoundGet, muteState, MASTER, MUTE, 1
         
         ; If sound was not already muted, we have to do it. Otherwise the user
         ; himself had muted the speakers so we must not do anything.
         If (muteState = "Off") {
            ; Mute the speakers...
            SoundSet, 1, MASTER, MUTE, 1
            ; ...and save the fact that WE have done that. This is necessary to
            ; reset the previous state after resuming from suspend mode.
            RegWrite, REG_DWORD, %reg_root%, %reg_path%, %reg_key%, 1
         }
      }
       
      ; PBT_APMRESUMESUSPEND oder PBT_APMRESUMESTANDBY? -> System wakes up
      If (wParam = 7 OR wParam = 8) {
         ; Did WE mute the speakers before?
         RegRead, muteState, %reg_root%, %reg_path%, %reg_key%
         
         ; If yes (muteState is 1), we have to switch on the speakers.
         ; Otherwise we do nothing because it was the user who had muted the speakers.
         If (muteState = "1") {
            RegWrite, REG_DWORD, %reg_root%, %reg_path%, %reg_key%, 0
            SoundSet, 0, MASTER, MUTE, 1
         }
      }
   }
   Return
}

You may need an icon called MuteOnHibernate.ico, located in the AutoHotkey program folder, or else put a semicolon in front of the line
Menu, TRAY, Icon, MuteOnHibernate.ico, 1, 1

This does not stop the beeps when you re-boot and may not work with Vista or 7, but I have it working with XP SP3 and I believe can be re-written to use the PowerShell.

I will investigate the code and see what needs to be done to stop beeps on shutdown or restart/ resume –unless a bright spark would care to beat me to it.

I hope that this is of interest to others.

_________________
IBM ThinkPad T43-2668-F5G,
T41p-2373-GEG & a T61-6466-9YG


Top
 Profile  
 
PostPosted: Wed Feb 10, 2010 10:38 am 
Offline
Junior Member
Junior Member

Joined: Tue Feb 14, 2006 2:17 pm
Posts: 438
Location: Bucks., UK
Extending the previous post, I have now added on the extra code to cut the sound off when you hibernate, shut down or restart. The complete script is listed below:

Code:
; AutoHotkey Version: 1.0.48.05
; Language:       English
; Platform:       XP SP3 (Not tested on other systems.)
; Version:       10 Feb 2010
; Author:         
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in

your Windows folder)
;

/*
   Mute on hibernation, restart or startup
   
   Purpose:
      Mute the internal speakers if the computer is sent into hibernation, restart
       or a subsequent startup
 
     
    IBM/Lenovo laptops, e.g. T43, produces a pause with an error message and two beeps
    at start up if the IBM hard disc is replaced with a on-IBM hard disc. While the error message
    will still be delayed, a BIOS change will set the start to continue after 3 seconds, but it
    still beeps. This script is designed to mute the sound at hibernation, etc. and turn it back on
    -unless, with hibernation, it had been turned off beforehand.

    With a  restart, or a subsequent startup, the sound is turned back on.
 

  BE AWARE:
       If there is a fult at boot time, IBM laptops give a series of beeps, which can be interpreted
      to determine the cause. This script will mask those beeps, although it is likely that an
      error message will be displayed. In such circumstances it may be necessary to disable
     this script.
   
   Functioning:
      The program runs in background, listening for the system´s message to hibernate
      the computer. It then mutes the speakers and turns them on again after the
      computer woke up.
      The mute state is left untouched in case the speakers were not muted by this
      program.
      The program will use one registry entry to save the mute state.
   
   Requirements:
      - Windows XP SP3
      - Read and write permission to HKEY_CURRENT_USER registry stem.
      - Registry entry HKEY_CURRENT_USER\SessionInformation\MutedforSuspend
      - AutoHotKey.exe
      - An icon called MuteOnHibernate.ico, for the system tray, or alternatively comment out
        the line 'Menu, TRAY, Icon, MuteOnHibernate.ico, 1, 1' below.
     
   Based on Script posted to www.autohotkey.com/forum/topic21697.html
   on Thu Aug 02, 2007 9:07 am   
   Post subject: Running commands on standby, hibernation and resume events
   by RobOtter
   Author:  Dirk Schwarzmann
   Version: 0.2
   Date:    2007-08-02
   
   Contact:
      Dirk 'Rob' Schwarzmann
      http://www.dirk-schwarzmann.de
      mailto://dirk@dirk-schwarzmann.de
   
   Version history:
      0.1, 2007-08-01: Initial version
      0.2, 2007-08-02: Replace unreliable timer function by real power event parameters
*/

; Registry location to save the mute state
reg_root = HKEY_CURRENT_USER
reg_path = SessionInformation
reg_key  = MutedforSuspend

; Tray icon and menu definition
Menu, TRAY, Icon, MuteOnHibernate.ico, 1, 1
Menu, TRAY, Tip, Mute speakers on hibernation

; Listen to the Windows power event "WM_POWERBROADCAST" (ID: 0x218):
; The DllCall is optional: it tells the OS to shut down this script first (prior to all other applications).
;
; Turn on the sound from Restart or Startup.
 SoundSet, 0, MASTER, MUTE, 1

DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0)

OnMessage(0x11, "func_WM_QUERYENDSESSION")
OnMessage(0x218, "func_WM_POWERBROADCAST")
Return

/*
   This function is executed if the system sends a power event.
   Parameters wParam and lParam define the type of event:
   
   lParam: always 0
   wParam:
      PBT_APMQUERYSUSPEND             0x0000
     
      PBT_APMQUERYSUSPENDFAILED       0x0002
     
      PBT_APMSUSPEND                  0x0004
     
      PBT_APMRESUMECRITICAL           0x0006
      PBT_APMRESUMESUSPEND            0x0007
     
      PBTF_APMRESUMEFROMFAILURE       0x00000001
     
      PBT_APMBATTERYLOW               0x0009
      PBT_APMPOWERSTATUSCHANGE        0x000A
     
      PBT_APMOEMEVENT                 0x000B
      PBT_APMRESUMEAUTOMATIC          0x0012
     
      Source: http://weblogs.asp.net/ralfw/archive/2003/09/09/26908.aspx
*/
func_WM_POWERBROADCAST(wParam, lParam)
{
   Global reg_root, reg_path, reg_key
   
   If (lParam = 0)
     {
      ; PBT_APMSUSPEND ? -> System will sleep

    If (wParam = 4)   
      {
         ; Get mute state
         SoundGet, muteState, MASTER, MUTE, 1
         
         ; If sound was not already muted, we have to do it. Otherwise the user
         ; himself had muted the speakers so we must not do anything.
         If (muteState = "Off")
       {
            ; Mute the speakers...
            SoundSet, 1, MASTER, MUTE, 1
            ; ...and save the fact that WE have done that. This is necessary to
            ; reset the previous state after resuming from suspend mode.
            RegWrite, REG_DWORD, %reg_root%, %reg_path%, %reg_key%, 1
         }
      }
     
      ; PBT_APMRESUMESUSPEND or PBT_APMRESUMEAUTOMATIC -> System wakes up
 
   If (wParam = 7 OR wParam = 12)
    {
         ; Did WE mute the speakers before?
         RegRead, muteState, %reg_root%, %reg_path%, %reg_key%
         
         ; If yes (muteState is 1), we have to switch on the speakers.
         ; Otherwise we do nothing because it was the user who had muted the speakers.
         If (muteState = "1")
        {
           RegWrite, REG_DWORD, %reg_root%, %reg_path%, %reg_key%, 0
            SoundSet, 0, MASTER, MUTE, 1
         }
      }
   }
   Return
}

;============================================================================
;Based on Script posted to www.autohotkey.com/forum/topic19103.html
;on Fri May 11, 2007 6:33 pm    Post subject: My script by 'psjw12'


func_WM_QUERYENDSESSION(wParam, lParam)
{

  ENDSESSION_LOGOFF = 0x80000000

  if (lParam & ENDSESSION_LOGOFF)
    Return
  else
  {
  ; Get mute state
         SoundGet, muteState, MASTER, MUTE, 1
         
         ; If sound was not already muted, we have to do it. Otherwise the user
         ; himself had muted the speakers so we must not do anything.
         If (muteState = "Off")
       {
            ; Mute the speakers...
            SoundSet, 1, MASTER, MUTE, 1
            ; ...and save the fact that WE have done that. This is necessary to
            ; reset the previous state after resuming from suspend mode.
            RegWrite, REG_DWORD, %reg_root%, %reg_path%, %reg_key%, 1
         }
  }
  Return
}



I hope that others find this useful.

Note: AutoHotKey allows one to compile the above, as I have done, and locate the .exe file with the system tray icon. A shortcut to the .exe in the startup folder will then cause the script to run from powering up.

_________________
IBM ThinkPad T43-2668-F5G,
T41p-2373-GEG & a T61-6466-9YG


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group