http://www.pcastuces.com/pratique/astuces/2665.htm
et puis ça :
http://lifehacker.com/5664251/toggle-po ... autohotkey
et en synthèse ça a donné ça :
Code : Tout sélectionner
#NoTrayIcon
#include <TrayConstants.au3>
Opt("TrayMenuMode", 3)
Local $mode1 = TrayCreateItem("Mode normal", -1, -1, 1)
Local $mode2 = TrayCreateItem("Toujours actif", -1, -1, 1)
TrayCreateItem("")
Local $idExit = TrayCreateItem("Quitter")
Local $pwrstate = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", "ActivePowerScheme")
If $pwrstate = "381b4222-f694-41f0-9685-ff5bb260df2e" Then
TraySetIcon(@WindowsDir & "\System32\powercpl.dll", 514)
TrayItemSetState($mode1, $TRAY_CHECKED)
ElseIf $pwrstate = "bde3f8e0-678f-4fa0-ae65-6023c24adf51" Then
TraySetIcon("powercpl.dll", 515)
TrayItemSetState($mode2, $TRAY_CHECKED)
Else
Exit
EndIf
TraySetToolTip("Options d'alimentation")
While 1
Switch TrayGetMsg()
Case $mode1
Run(@WindowsDir & "\System32\powercfg.exe -setactive 381b4222-f694-41f0-9685-ff5bb260df2e","",@SW_HIDE)
TraySetIcon(@WindowsDir & "\System32\powercpl.dll", 514)
TrayItemSetState($mode1, $TRAY_CHECKED)
Case $mode2
Run(@WindowsDir & "\System32\powercfg.exe -setactive bde3f8e0-678f-4fa0-ae65-6023c24adf51","",@SW_HIDE)
TraySetIcon("powercpl.dll", 515)
TrayItemSetState($mode2, $TRAY_CHECKED)
Case $idExit
ExitLoop
EndSwitch
WEnd