#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ModernPowerLogov2.ico #AutoIt3Wrapper_Outfile_x64=..\..\Logiciels\ModernPower.exe #AutoIt3Wrapper_Res_Comment=Modern Power #AutoIt3Wrapper_Res_Description=Modern Power #AutoIt3Wrapper_Res_Fileversion=2.0.1.2 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_ProductName=Modern Power v2 #AutoIt3Wrapper_Res_ProductVersion=2.0.0.0 #AutoIt3Wrapper_Res_CompanyName=Tyleo Softwares #AutoIt3Wrapper_Res_LegalCopyright=Tyleo Softwares #AutoIt3Wrapper_Res_LegalTradeMarks=Tyleo Softwares #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include "TyleoAboutMe.au3" #include "MetroGUI-UDF\MetroGUI_UDF.au3" #include #Region ### START Koda GUI section ### Form= $GeneralSound = "C:\Windows\Media\Windows Balloon.wav" PlayIt() $AlphaDefault = "210" $AlphaINI = @AppDataDir & "\ModernPower_Alpha.ini" If FileExists($AlphaINI) Then ; Nothing Else IniWrite($AlphaINI,"Alpha for Modern Power","ALPHA",$AlphaDefault) EndIf $AlphaActive = IniRead($AlphaINI,"Alpha for Modern Power","ALPHA",$AlphaDefault) $LightMode = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme") $theMWTitleBarColor = Hex(RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "AccentColor")) $theMWTitleBarColor = StringRight($theMWTitleBarColor, 6) $theMWTitleBarColor = "0x" & StringRight($theMWTitleBarColor, 2) & StringMid($theMWTitleBarColor, 3, 2) & StringLeft($theMWTitleBarColor, 2) $CurrentAccent = $theMWTitleBarColor $LightTh = "LightGray" $DarkTh = "DarkRuby" if $LightMode = "1" Then $ThemeActive = $LightTh Else $ThemeActive = $DarkTh EndIf _SetTheme($ThemeActive) $ButtonBKColor = $CurrentAccent $CurrentVer = FileGetVersion(@AutoItExe) $State = " STABLE THAURUS" $Soft = "Modern Power " & $CurrentVer & $State ; DEFAULT EN_US $lang_REBOOT = "REBOOT" $lang_POWER = "POWER DOWN" $lang_LOCK = "LOCK" $lang_LOGOUT = "DISCONNECT" $lang_RELOADEXP = "RELOAD EXPLORER" $lang_CONFIRM = "Confirm the selected action by clicking Yes." $lang_REXP_DONE = "Explorer Restarted !" $lang_NOTSUPPORTED = "Your computer does'nt support reboot to UEFI / BIOS" $lang_STANDBY = "STAND BY" ; FRENCH MOD if FileExists(@ScriptDir & "\fr") Then $lang_REBOOT = "REDEMARRER" $lang_POWER = "ARRETER" $lang_LOCK = "VERR" $lang_LOGOUT = "DECONNECTER" $lang_RELOADEXP = "RECHARGER EXPLORER" $lang_STANDBY = "MISE EN VEILLE" $lang_CONFIRM = "Confirmez l'action séléctionnée en cliquant sur Yes." $lang_REXP_DONE = "Explorateur Redémarré !" $lang_NOTSUPPORTED = "Votre ordinateur ne supporte pas le redémarrage vers l'UEFI / BIOS" EndIf Global $PowerMenu = _Metro_CreateGUI($Soft,867,65,-1,15) $Lock = _Metro_CreateButtonEx2($lang_LOCK,12,13,60,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $PowerDown = _Metro_CreateButtonEx2($lang_POWER,73,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $Reboot = _Metro_CreateButtonEx2($lang_REBOOT,224,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $Logout = _Metro_CreateButtonEx2($lang_LOGOUT,375,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $StandBy = _Metro_CreateButtonEx2($lang_STANDBY,526,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $ReloadExp = _Metro_CreateButtonEx2($lang_RELOADEXP,677,13,150,48,$CurrentAccent,0xFFFFFF,"Segoe UI",11,1,0x000000) $Close = _Metro_CreateButtonEx2("❌",845,4 + 10,17,17,$CurrentAccent,0xFF5151,"Segoe UI",7.5) $UnDim = _Metro_CreateButtonEx2("/",845,19 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) $About = _Metro_CreateButtonEx2("?",845,34 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) $Force = _Metro_CreateButtonEx2("F",828,4 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) $Dim = _Metro_CreateButtonEx2("\",828,19 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) $Firmware = _Metro_CreateButtonEx2("W",828,34 + 10,17,17,$CurrentAccent,0xFFFFFF,"Segoe UI",7.5) GUICtrlSetTip($Firmware,"Firmware") GUICtrlSetTip($Dim,"Dim") GUICtrlSetTip($UnDim,"UnDim") GUICtrlSetTip($Force,"Force Shutdown") GUICtrlSetTip($Close,"Close") GUICtrlSetTip($About,"About") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $hGUI=GUICreate("",@DesktopWidth,@DesktopHeight,0,0,0x80000000,0x08000080) WinSetTrans($hGUI, "", $AlphaActive) GUISetBkColor($CurrentAccent) WinSetState($hGUI, "", @SW_SHOW) WinSetOnTop($PowerMenu, "", 1) HotKeySet("{ESCAPE}","Echap") Local $MsgBox_Form _Gui_RoundCorners($PowerMenu,11,11,11,11) While 1 $nMsg = GUIGetMsg() WinSetOnTop($PowerMenu, "", 1) Switch $nMsg Case $UnDim PlayIt() HideIt() Case $Dim PlayIt() UnHideIt() Case $StandBy Shutdown($SD_STANDBY) Exit(0) Case $Firmware PlayIt() $Confirm = _Metro_MsgBox(4,"FIRMWARE",$lang_CONFIRM & @CRLF & "REBOOT TO UEFI FIRMWARE (MUST BE POSSIBLE)",370) PlayIt() If $Confirm = "Yes" Then Run("shutdown /fw /r","",@SW_HIDE) Sleep(250) _Metro_MsgBox(0,"NO UEFI / UEFI VERSION NOT SUPPORTED",$lang_NOTSUPPORTED) PlayIt() Endif Case $PowerDown PlayIt() $Confirm = _Metro_MsgBox(4,$lang_POWER,$lang_CONFIRM,370) PlayIt() If $Confirm = "Yes" Then Run("shutdown -p","",@SW_HIDE) Exit(0) Endif Case $Force PlayIt() $Confirm = _Metro_MsgBox(4,"EMERGENCY MODE",$lang_CONFIRM & @CRLF & "EMERGENCY MODE - FORCE SHUTDOWN",370) PlayIt() If $Confirm = "Yes" Then Run("taskkill /im explorer.exe /f","",@SW_HIDE) Run("taskkill /im chrome.exe /f","",@SW_HIDE) Run("taskkill /im msedge.exe /f","",@SW_HIDE) Run("taskkill /im firefox.exe /f","",@SW_HIDE) Run("taskkill /im opera.exe /f","",@SW_HIDE) Run("taskkill /im maxthon.exe /f","",@SW_HIDE) Run("shutdown -p -f","",@SW_HIDE) Exit(0) Endif Case $Reboot PlayIt() $Confirm = _Metro_MsgBox(4,$lang_REBOOT,$lang_CONFIRM,370) PlayIt() If $Confirm = "Yes" Then Run("shutdown -r -t 00","",@SW_HIDE) Exit(0) Endif Case $Lock PlayIt() Sleep(220) Run("Rundll32.exe user32.dll,LockWorkStation","",@SW_HIDE) Exit(0) Case $Logout PlayIt() $Confirm = _Metro_MsgBox(4,$lang_LOGOUT,$lang_CONFIRM,370) PlayIt() If $Confirm = "Yes" Then Run("shutdown -l","",@SW_HIDE) Exit(0) Endif Case $ReloadExp PlayIt() Run("taskkill /im explorer.exe /f","",@SW_HIDE) Sleep(1200) ShellExecute("explorer") Sleep(1000) PlayIt() _Metro_MsgBox(0,"",$lang_REXP_DONE,200) WinSetOnTop($hGUI, "", 1) WinSetOnTop($PowerMenu, "", 1) Case $Close PlayIt() Sleep(220) Exit(0) Case $About PlayIt() TyleoAbout($Soft) PlayIt() EndSwitch WEnd Func ForceTop() WinSetOnTop($hGUI, "", 1) WinSetOnTop($PowerMenu, "", 1) EndFunc Func HideIt() WinSetState($hGUI,"",@SW_HIDE) EndFunc Func UnHideIt() WinSetState($hGUI,"",@SW_SHOW) EndFunc Func Echap() GUIDelete($hGUI) Exit(0) EndFunc Func PlayIt() if FileExists($GeneralSound) Then SoundPlay($GeneralSound,0) EndIf EndFunc Func _Gui_RoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Local $XS_pos, $XS_ret, $XS_ret2 $XS_pos = WinGetPos($h_win) $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", _ $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3) If $XS_ret[0] Then $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", _ $XS_ret[0], "int", 1) EndIf EndFunc