We've featured a way to switch power management plans with a hotkey, but if you'd rather not mess with the command line (or if you're just more of a mouse user), you can add a simple button to your Windows taskbar instead.
All you need to do to get this script working is download it and throw it into your Startup folder. You'll see an icon in your taskbar from which you can toggle power plans with a single click, as well as change the brightness by right-clicking. It's a bit quicker than Windows' battery icon, and much easier to set up than our earlier method — just put it in a folder and forget it.
If you'd like to add the code to your own AutoHotkey scripts, you can copy it from the box below:
#Persistent #SingleInstance force Menu, Tray, NoStandard ; only use this menu Menu, Tray, Click, 1 ; Remove this line if you prefer double-click vs. single-click. menu, tray, tip, toggle power plan RegRead, PowerState, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes, ActivePowerScheme if(PowerState = "a1841308-3541-4fab-bc81-f71556f20b4a") { menu, tray, icon, %SystemRoot%\System32\powercpl.dll, 8 } else { menu, tray, icon, %SystemRoot%\System32\powercpl.dll, 7 } Menu, Tray, Add, Toggle, Toggle Menu, Tray, Default, Toggle Menu, Tray, Add, Adjust brightness, Brightness Menu, Tray, Add, Exit, Exit return Toggle: RegRead, PowerState, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes, ActivePowerScheme if(PowerState = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c") { Run, %SystemRoot%\System32\powercfg.exe -setactive a1841308-3541-4fab-bc81-f71556f20b4a, , hide } else { Run, %SystemRoot%\System32\powercfg.exe -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c, , hide } Sleep 200 GoSub, Icon Sleep 1800 GoSub, Icon return Brightness: Run, C:\Windows\explorer.exe shell:::{025A5937-A6BE-4686-A844-36FE4BEC8B6D} Sleep 100 return Exit: ExitApp Icon: Sleep 100 RegRead, PowerState, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes, ActivePowerScheme if(PowerState = "a1841308-3541-4fab-bc81-f71556f20b4a") { menu, tray, icon, %SystemRoot%\System32\powercpl.dll, 8 } else { menu, tray, icon, %SystemRoot%\System32\powercpl.dll, 7 } return
Comments
Is there anything you guys can do about the annoying bug on lifehacker, all backslash chars get stripped, perhaps you need to do adouble backslash to escape it or it needs a coding change, otherwise its annoying task for readers to fix (if its one line, very annoying if a big script like this).
Also your missing a % in the first menu item.
Have fixed the backslash error here and will get our tech guys to look into it for future code segments.
Thanks for the quick fix.
Hi,
I had to change the double quotes before it would work for me:
“a1841308-3541-4fab-bc81-f71556f20b4a”
to
"a1841308-3541-4fab-bc81-f71556f20b4a"
Modified it then to suit my schemes.
Thanks,
dRdoS7.
Join the discussion!
Comment Voting
Up Votes
Down Votes
Only logged in users may vote for comments!
Please log in or register to gain access to this feature.
Get Permalink