Jump to content



Photo

Set On Lid Close Power Option


  • Please log in to reply
2 replies to this topic

#1 ken82m

ken82m

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 623 posts

Posted 27 November 2008 - 06:55 PM

I figured this out for someone on the support forum.
I don't know if anyone else will find a use for it but I thought I'd throw it up anyway.

It quite simple sets the value in:
Control Panel>Power Options>Advanced Tab>When I Close The Lid of My Portable Computer

You have three options: Do Nothing , Standby , Hibernate

Enjoy.

Kenny

Plain Text         
#cs --------------------------------------------------------------------------------------  AutoIt Version: 3.2.13.11 (beta)  Author:         Kenneth P. Morrissey (Kenny782)  Script Function:     This function will allow you to control the action when you close the lid on     your laptop. The corresponding combobox is in Power Options>Advanced Tab.      Syntax:     _SetLidPowerAction ( $sAction )      Parameters:     $sAction:       The action you would like to set on closing the laptops lid.                         00 - Do Nothing                         02 - Standby                         03 - Hibernate  Returns:                      Success: Returns 1                      Failure: Returns 0                         Sets @error to 1 - Invalid Parameter                         Sets @error to 2 - Could not read or verify current settings                         Sets @error to 2 - Error writing new registry value  Notes:              I have only tested this on XP. The values or position could be                      different on other OS's. I added a verification to make sure the                      the current values match one of the three settings. But you should                      still backup the following key before trying it on say Vista                      "HKCU\Control Panel\PowerCfg\GlobalPowerPolicy"  Example:                      _SetLidPowerAction(02) #ce --------------------------------------------------------------------------------------   Func _SetLidPowerAction($sAction)     If $sAction <> 00 AND $sAction <> 02 AND $sAction <> 03 Then         SetError(1)         Return 0     EndIf     $Key = RegRead("HKCU\Control Panel\PowerCfg\GlobalPowerPolicy", "Policies")     If $Key = "" Then         SetError(2)         Return 0     EndIf     $Key = StringReplace($Key, 106, $sAction)     $Key = StringReplace($Key, 130, $sAction)     If $sAction <> 00 Then         $Key = StringReplace($Key, 127, 00)         $Key = StringReplace($Key, 151, 00)     Else         $Key = StringReplace($Key, 127, 80)         $Key = StringReplace($Key, 151, 80)     EndIf     If $Key <> "" Then         If RegWrite("HKCU\Control Panel\PowerCfg\GlobalPowerPolicy", "Policies", "REG_BINARY", $Key) = 1 Then             RunWait(@ComSpec & " /c rundll32.exe powrprof.dll,LoadCurrentPwrScheme", @SystemDir, @SW_HIDE)             Return 1         EndIf     EndIf     SetError(3)     Return 0 EndFunc

Edited by ken82m, 27 November 2008 - 07:08 PM.

My ContributionsPC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs ScriptIT Help Desk and System Information ToolSet On Lid Close Power Option - Streaming Media Server & Website”I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains.”







#2 enggniteshgarg

enggniteshgarg

    Seeker

  • Active Members
  • 8 posts

Posted 01 February 2012 - 12:29 PM

Hi ken82m,
I want to pull the sleep time value and power button action using registry. Is it possible?
Do you have any idea?

#3 funkey

funkey

    New Dad

  • Active Members
  • PipPipPipPipPipPip
  • 484 posts

Posted 02 February 2012 - 04:51 PM

ken82m was: Last Active Sep 21 2011 07:56 AM :)

Edited by funkey, 02 February 2012 - 04:51 PM.

Programming today is a race between software engineers striving to

build bigger and better idiot-proof programs, and the Universe

trying to produce bigger and better idiots.

So far, the Universe is winning.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users