I can't upload images and don't have a website to link, so you will have to furnish your own. Images: Background w172 h101; 12 buttons w22 h22 (6 for down and 6 for up positions); 1 w12 h12 for close. Leave any questions and I will check back later.
Code:
#NoTrayIcon
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetBatchLines, -1
IniRead, left, Options.ini, Position, left
IniRead, top, Options.ini, Position, top
Gui, Font, s9, Tahoma
Gui, Add, Picture, x0 y0, Images\BG.png
Gui, Add, Text, xm25 ym0 cWhite center BackgroundTrans, Select a button...
Gui, Add, Picture, xm-2 ym+25 gShutdown vButShutDown, Images\ShutDownUp.png
Gui, Add, Picture, xm+25 ym+25 gRestart vButRestart, Images\RestartUp.png
Gui, Add, Picture, xm+52 ym+25 gLogOff vButLogOff, Images\LogOffUp.png
Gui, Add, Picture, xm+79 ym+25 gLockPC vButLockPC, Images\LockPCUp.png
Gui, Add, Picture, xm+106 ym+25 gSuspend vButSuspend, Images\SuspendUP.png
Gui, Add, Picture, xm+133 ym+25 gHibernate vButHibernateUp, Images\HibernateUP.png
Gui, Add, Text, xm+0 ym+50 w140 r2 cWhite center BackgroundTrans, Clock
Gui, Add, Picture, xm+144 ym+1 gClose vButClose, Images\Close.png
Gui, -Caption +ToolWindow
Gui, Show, x%left% y%top% w172 h101, Power Options
;WinSet, Region, 0-0 172-0 172-95 0-95 w172 h101 r20-20, Power Options ;Set the color black as transparent
OnMessage(0x112, "WM_SYSCOMMAND")
OnMessage(0x200, "WM_MOUSEMOVE") ; add this line in the auto-execute section
OnMessage(0x201, "WM_LBUTTONDOWN") ; add this line in the auto-execute section
;#Persistent
settimer, update, 1000
Gosub Update
; Intercept Win+D are pressed to minimize the desktop.
#d::
Send, {LWin down}{d} ; Force Win+D after inteception.
Send, {LWin up}{d} ; Restore LWin in up posiiton.
Sleep, 50 ; Required to allow desktop to be minimized.
WinActivate, Power Options ; Restore window immediately.
Return
Update:
FormatTime, var, , MMM. dd,yyyy HH:mm:ss
GuiControl,,Static9, % var
Return
WM_LBUTTONDOWN(wParam, lParam)
{
If !A_GuiControl ; Enable window dragging.
PostMessage, 0xA1, 2 ; 0xA1 = WM_NCLBUTTONDOWN Does not work on clickable control.
WinGetPos, left, top, , , Power Options ; Track position of window and
IniWrite, %left%, Options.ini, Position, left ; save for next time
IniWrite, %top%, Options.ini, Position, top ; it is opened.
}
; Set message at top of window and change cursor.
WM_MOUSEMOVE()
{ hCursor := DllCall("LoadCursor", "Uint", NULL, "Int", 32649, "Uint")
oldCursor := DllCall("SetCursor", "uint", hCursor)
MouseGetPos, , , , ctrl
If ctrl = Static3
GuiControl,, Static2, Shutdown
Else If ctrl = Static4
GuiControl,, Static2, Restart
Else If ctrl = Static5
GuiControl,, Static2, Log Off
Else If ctrl = Static6
GuiControl,, Static2, Lock PC
Else If ctrl = Static7
GuiControl,, Static2, Suspend (Sleep)
Else If ctrl = Static8
GuiControl,, Static2, Hibernate
Else
{
sleep, 100
GuiControl,, Static2, Select a button...
DllCall("SetCursor", "uint", oldCursor)
}
If ctrl = Static10
tooltip, Close
Else
Tooltip
sleep, 10
}
; First 3 options will clear all programs so a message box is needed.
Shutdown:
GuiControl, , ButShutDown, Images\ShutDownDn.png
KeyWait, LButton, U
GuiControl, , ButShutDown, Images\ShutDownUp.png
MsgBox, 36,, Shutdown computer? (press Yes or No)
IfMsgBox Yes
Run, Shutdown.exe /p ; Shutdown
Return
Restart:
GuiControl, , ButRestart, Images\RestartDn.png
KeyWait, LButton, U
GuiControl, , ButRestart, Images\RestartUp.png
MsgBox, 36,, Restart computer? (press Yes or No)
IfMsgBox Yes
Run, shutdown.exe -r -t 0 -f ; Restart
Return
LogOff:
GuiControl, , ButLogOff, Images\LogOffDn.png
KeyWait, LButton, U
GuiControl, , ButLogOff, Images\LogOffUp.png
MsgBox, 36,, Log off computer? (press Yes or No)
IfMsgBox Yes
Run, Shutdown.exe /l ; Logoff
Return
LockPC:
GuiControl, , ButLockPC, Images\LockPCDn.png
KeyWait, LButton, U
GuiControl, , ButLockPC, Images\LockPCUp.png
Run rundll32 user32.dll LockWorkStation
Return
Suspend:
GuiControl, , ButSuspend, Images\SuspendDn.png
KeyWait, LButton, U
GuiControl, , ButSuspend, Images\SuspendUp.png
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)Return
Return
Hibernate:
GuiControl, , ButHibernate, Images\HibernateDn.png
KeyWait, LButton, U
GuiControl, , ButHibernate, Images\HibernateUp.png
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)Return
Return
Close:
GuiClose:
ExitApp