Belini Posted March 19, 2018 Posted March 19, 2018 (edited) I need to turn off my notebook every time the cover is closed, does anyone know how to identify when the notebook's cover has been closed? Edited March 20, 2018 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Moderators JLogan3o13 Posted March 19, 2018 Moderators Posted March 19, 2018 Why not just use power settings to do this? Under options for closing the lid (Windows 7 and above) there is an option to shut the device down "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Belini Posted March 19, 2018 Author Posted March 19, 2018 I wanted to do it by code, ie to monitor the cover and turn it off when it is closed, so that I do not have to configure all the notebook's that I'm going to use the program! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Earthshine Posted March 19, 2018 Posted March 19, 2018 (edited) then automate the setting of that power option if you can. Edited March 19, 2018 by Earthshine My resources are limited. You must ask the right questions
Belini Posted March 19, 2018 Author Posted March 19, 2018 @Earthshine I tried to edit the registry following your advice but it did not work, I need it to look like this: - Power off when you press the power button- off when you close the cover My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
BrewManNH Posted March 19, 2018 Posted March 19, 2018 You want to be able to do this to OTHER people's computers? Are you giving them the option to not let you do this when they run your program? I know I'd be PISSED if your program did this to my computer without telling me. Earthshine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Earthshine Posted March 19, 2018 Posted March 19, 2018 1 hour ago, Belini said: @Earthshine I tried to edit the registry following your advice but it did not work, I need it to look like this: - Power off when you press the power button- off when you close the cover did you reboot? or at least log off and on again after making registry change? My resources are limited. You must ask the right questions
Earthshine Posted March 19, 2018 Posted March 19, 2018 oh and i found this Belini 1 My resources are limited. You must ask the right questions
Belini Posted March 19, 2018 Author Posted March 19, 2018 1 hour ago, BrewManNH said: You want to be able to do this to OTHER people's computers? Are you giving them the option to not let you do this when they run your program? I know I'd be PISSED if your program did this to my computer without telling me. They are all notebooks of mine that will only be used to run my program and nothing else, will not have taskbar, explorer and nor to the task manager! 1 hour ago, Earthshine said: oh and i found this @Earthshine is now turning it off when the lid is closed, thanks for the help! Run("powercfg.exe -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "",@SW_HIDE) Run("powercfg.exe -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "",@SW_HIDE) Now to be perfect, i only need to know how to turn it off when the power button is pressed! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Belini Posted March 20, 2018 Author Posted March 20, 2018 I was able to find it here: https://social.msdn.microsoft.com/Forums/en-US/06bdec1d-4ffa-4a4a-b381-9265c304cc85/command-line-configuration-of-power-button-function?forum=quebecmisc Run("powercfg.exe -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -powercfg.exe -SETACVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -powercfg.exe -SETDCVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3", "C:\WINDOWS\system32", @SW_HIDE) Earthshine 1 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
AdamUL Posted March 20, 2018 Posted March 20, 2018 I know you already found your answer. I thought it would be helpful to show a function that sets multiple power options, including what you wanted. expandcollapse popupFunc _SetPowerOptions() ;Set multiple power options. ;Set the current power plan standby timeout ("Put the computer to sleep") to "Never". Local $iPowercfgReturn = RunWait("powercfg -x standby-timeout-ac 0", '', @SW_HIDE) If @error Or $iPowercfgReturn <> 0 Then Return SetError(1, 0, False) ;Set monitor timeout ("Turn off the display") to 30 minutes. $iPowercfgReturn = RunWait("powercfg -x monitor-timeout-ac 30", '', @SW_HIDE) If @error Or $iPowercfgReturn <> 0 Then Return SetError(2, 0, False) Local $s64Bit = "" If @OSArch = "X64" Then $s64Bit = "64" ;Disable Hibernate. Local Const $sRegKeyPower = "HKEY_LOCAL_MACHINE" & $s64Bit & "\SYSTEM\CurrentControlSet\Control\Power" Local $iRegWriteReturn = RegWrite($sRegKeyPower, "HibernateEnabled", "REG_DWORD", 0) If @error Or $iRegWriteReturn <> 1 Then Return SetError(3, @error, False) Local Const $sRegKeyPowerSettings = "HKEY_LOCAL_MACHINE" & $s64Bit & "\SOFTWARE\Policies\Microsoft\Power\PowerSettings" ;Disable Sleep in the Start Menu. Local Const $sRegKeyPowerSettingsSleepStartMenu = $sRegKeyPowerSettings & "\abfc2519-3608-4c2a-94ea-171b0ed546ab" $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsSleepStartMenu, "ACSettingIndex", "REG_DWORD", 0) If @error Or $iRegWriteReturn <> 1 Then Return SetError(4, @error, False) $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsSleepStartMenu, "DCSettingIndex", "REG_DWORD", 0) If @error Or $iRegWriteReturn <> 1 Then Return SetError(5, @error, False) ;Set Sleep Button to "Do Nothing" Local Const $sRegKeyPowerSettingsSleepButton = $sRegKeyPowerSettings & "\96996BC0-AD50-47EC-923B-6F41874DD9EB" $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsSleepButton, "ACSettingIndex", "REG_DWORD", 0) If @error Or $iRegWriteReturn <> 1 Then Return SetError(6, @error, False) $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsSleepButton, "DCSettingIndex", "REG_DWORD", 0) If @error Or $iRegWriteReturn <> 1 Then Return SetError(7, @error, False) ;Set Power Button to "Shut down" Local Const $sRegKeyPowerSettingsPowerButton = $sRegKeyPowerSettings & "\7648EFA3-DD9C-4E3E-B566-50F929386280" $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsPowerButton, "ACSettingIndex", "REG_DWORD", 3) If @error Or $iRegWriteReturn <> 1 Then Return SetError(8, @error, False) $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsPowerButton, "DCSettingIndex", "REG_DWORD", 3) If @error Or $iRegWriteReturn <> 1 Then Return SetError(9, @error, False) ;Set "When I close the lid" to "Shut down" Local Const $sRegKeyPowerSettingsCloseLid = $sRegKeyPowerSettings & "\5CA83367-6E45-459F-A27B-476B1D01C936" $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsCloseLid, "ACSettingIndex", "REG_DWORD", 3) If @error Or $iRegWriteReturn <> 1 Then Return SetError(10, @error, False) $iRegWriteReturn = RegWrite($sRegKeyPowerSettingsCloseLid, "DCSettingIndex", "REG_DWORD", 3) If @error Or $iRegWriteReturn <> 1 Then Return SetError(11, @error, False) Return True EndFunc ;==>_SetPowerOptions Adam Belini 1
Belini Posted March 21, 2018 Author Posted March 21, 2018 Thanks @AdamUL will be very useful this information to change directly in the registry too! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Earthshine Posted March 21, 2018 Posted March 21, 2018 @Belini you should change the first post of this thread's title to add the word SOLVED to it so others with this issue can see there is a solution. Thanks My resources are limited. You must ask the right questions
Belini Posted March 21, 2018 Author Posted March 21, 2018 I did not find the option to mark as resolved by this I just changed the topic title! Earthshine 1 My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Earthshine Posted March 21, 2018 Posted March 21, 2018 That’s exactly how you do it My resources are limited. You must ask the right questions
Belini Posted March 21, 2018 Author Posted March 21, 2018 This I had done before you spoke! My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ
Earthshine Posted March 21, 2018 Posted March 21, 2018 ok. sweet. thanks. My resources are limited. You must ask the right questions
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now