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.





