if A_IsCompiled
{
IfNotExist, Shutdown.res
{
FileCreateDir, Shutdown.res ; Создаём папку для ресурсов
FileSetAttrib, +H, Shutdown.res ; Делаем её скрытой
}
FileInstall, Shutdown.res\RestartFon.png, Shutdown.res\RestartFon.png, 0 ; ЛОГО... далее PNG-кнопки
FileInstall, Shutdown.res\TurnOff.png, Shutdown.res\TurnOff.png, 0
FileInstall, Shutdown.res\Reload.png, Shutdown.res\Reload.png, 0
FileInstall, Shutdown.res\LogOff.png, Shutdown.res\LogOff.png, 0
FileInstall, Shutdown.res\ESC.png, Shutdown.res\ESC.png, 0
FileInstall, Shutdown.res\Shutdown.ico, Shutdown.res\Shutdown.ico, 0
}
vWDResus := A_WorkingDir "\Shutdown.res\"
Gui Gray:New, +LastFound +AlwaysOnTop -Caption +ToolWindow +HwndMyGuiHwnd
Gui, Gray:Default
Gui , Color, 0
WinSet, Transparent, 200
Gui, Show, x0 y0 NoActivate W%A_ScreenWidth% H%A_ScreenHeight%
Gui, Default
cSps := " ", cTRD := "BackgroundTrans"
vWinName := "Windows 7"
Gui, New , +OwnDialogs -caption +AlwaysOnTop +HwndMyFocus , %vWinName%
Gui, Margin , 0, 0 ; без caption
vPath := vWDResus "RestartFon.png"
Gui, Add, Picture, x0 y0 w580 h435 , %vPath%
xPosDef := 512, yPosDef := 365 ;Позиция курсора мышки по умолчанию
; Значения cWd и cHd - не передаются в окно
vXPos := 460, vYPos := 320, cWd := 100, cHd := 100, lbName := "Reload", vPath := vWDResus "Reload.png"
vlbName := "v" lbName cSps "g" lbName, btReload := "x" vXPos cSps "y" vYPos cSps cTRD cSps "v" lbName cSps "g" lbName
Gui, Add, Picture, %btReload%, %vPath%
vXPos := 25, vYPos := 320, cWd := 100, cHd := 100, lbName := "TurnOff", vPath := vWDResus "TurnOff.png"
vlbName := "v" lbName cSps "g" lbName, btReload := "x" vXPos cSps "y" vYPos cSps cTRD cSps "v" lbName cSps "g" lbName
Gui, Add, Picture, %btReload%, %vPath%
vXPos := 260, vYPos := 320, cWd := 100, cHd := 100, lbName := "LogOff", vPath := vWDResus "LogOff.png"
vlbName := "v" lbName cSps "g" lbName, btReload := "x" vXPos cSps "y" vYPos cSps cTRD cSps "v" lbName cSps "g" lbName
Gui, Add, Picture, %btReload%, %vPath%
vXPos := 410, vYPos := 10, cWd := 120, cHd := 120, lbName := "ESC", vPath := vWDResus "ESC.png"
vlbName := "v" lbName cSps "g" lbName, btReload := "x" vXPos cSps "y" vYPos cSps cTRD cSps "v" lbName cSps "g" lbName
Gui, Add, Picture, %btReload%, %vPath%
Gui, Show, xCenter yCenter
;SetTimer lbTopWinLogo, 25
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *!Tab, TabPressed
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *LButton, LBpressed
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *XButton1, TabPressed
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *XButton2, TabPressed
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *MButton, TabPressed
Hotkey, IfWinExist, ahk_id %MyFocus%
Hotkey, *RButton, TabPressed
MouseMove, xPosDef, yPosDef
return
LWin Up::
RWin Up::
return
GuiClose:
GuiEscape:
;SetTimer lbTopWinLogo, off
Return
TurnOff:
vRunsLabel := A_ThisLabel, vFnGUI := "TurnOff", vStock := False
Gosub gExecGUI
Return
Reload:
vRunsLabel := A_ThisLabel, vFnGUI := "Reload", vStock := False
Gosub gExecGUI
Return
LogOff:
vRunsLabel := A_ThisLabel, vFnGUI := "LogOff", vStock := False
Gosub gExecGUI
Return
ESC:
vRunsLabel := A_ThisLabel, vFnGUI := "ESC", vStock := False
Gosub gExecGUI
Return
LBpressed:
MouseGetPos,,,OutputVarWin
if (MyFocus = OutputVarWin)
Click
return
TabPressed:
return
/*
shutdown -r — restarts
shutdown -s — shutsdown
shutdown -l — logoff
shutdown -t xx — where xx is number of seconds to wait till shutdown/restart/logoff
shutdown -i — gives you a dialog box to fill in what function you want to use
shutdown -a — aborts the previous shutdown command....very handy!
Завершение сеанса 0
Завершение работы 1
Перезагрузка 2
Закрытие всех приложений 4
Выключение питания 8 это тоже что Завершение работы 1
Нужные значения складываются.
Например, код для завершения работы и выключения питания будет 9 (1+8).
Можно использовать и выражения вида 1+8.
*/
gExecGUI:
GuiControl, Hide, %vFnGUI%
KeyWait, Lbutton
Sleep 500
GuiControl, Show, %vFnGUI%
Sleep 1000
Gosub GuiClose
If (vFnGUI = "TurnOff")
{
shutdown, 9
ExitApp
}
If (vFnGUI = "Reload")
{
; Force a reboot (reboot + force = 2 + 4 = 6):
Shutdown, 6
ExitApp
}
If (vFnGUI = "LogOff")
{
shutdown, 0
ExitApp
}
If (vFnGUI = "ESC")
ExitApp
Return
/*
lbTopWinLogo:
if (!WinActive(vWinName))
WinActivate, %vWinName%
MouseGetPos, OutputVarX, OutputVarY, OutputVarWin
if (MyFocus = OutputVarWin)
ToolTip X= %OutputVarX% `n Y= %OutputVarY%
return
*/