XP Shutdown/Logoff Menu for Windows 10 x64 (v0.973 beta)
Jan.12 2021
Here is the package with all 4 AHKs in it: XP_Logoff, XP_Shutdown, XP_Settings (and please remember to compile "misc\fade.ahk" as well, code posted below) Here is the download page with the compiled x86 EXEs etc for non-ahk users:
http://weedtrek.ca/XPshutdown.html
Comments and questions can be left below, or at my personal email: blackwidowfarms (at) hotmail.com
Here is the code for "XP_Logoff":
Code: Select all
#SingleInstance, force ; forces new instance of script
#Persistent ; keeps script active
#NoTrayIcon ; hides tray icon
SetBatchLines, -1 ; runs at full speed
SetWorkingDir %A_ScriptDir% ; sets script directory as working directory
OnExit, OnExitCommand ; if script exits by any method, OnExitCommand subroutine is run
#Include, misc\functions.ahk ; gets shared program functions
Process, Close, XP_Shutdown.exe ; terminates this 64-bit process
Process, Close, XP_Settings.exe ; terminates this 64-bit process
IniRead, Language, misc\options.ini, MainOptions, Language, English ; gets chosen language, "English" if error
IniRead, DesktopChange, misc\options.ini, MainOptions, DesktopChange, 0 ; gets "change desktop" information, "No" if error
IniRead, FadeInTips, misc\options.ini, MainOptions, FadeInTips, 0 ; gets "fade-in bubble-tips" information, "No" if error
if DesktopChange = 1 ; if "Desktop FX" is "Yes"...
gosub, TurnOnHotkeys ; disables keys and mouse clicks, makes "ding" sound instead
Loop, 33 ; reads INI file for keys' contents
{
IniRead, Text%A_Index%, misc\options.ini, %Language%, key%A_Index% ; reads each key and assigns to variable
StringReplace, Text%A_Index%, Text%A_Index%, ||, `n, All ; replaces pipe-delimiters with line breaks for accuracy
}
Gui, Default: New
Gui, Default: Color, black ; GUI background color, makes 1px black border effect
Gui, Default: Add, Picture, x1 y1 w313 h198, images\Bitmap20142.png ; exact PNG copy of Windows background BMP image
Gui, Default: Add, Picture, x266 y2 w48 h40, images\Bitmap20141.png ; exact PNG copy of Windows logo BMP image
AddGraphicBtn("x84","y82","h32","w32","Btn1","images\SwitchUser.png","images\SwitchUserHover.png","images\SwitchUserDown.png") ; loads all 3 states of "Switch User" button
AddGraphicBtn("x199","y82","h32","w32","Btn2","images\LogOff.png","images\LogOffHover.png","images\LogOffDown.png") ; loads all 3 states of "Log Off" button
ButtonCount = 2 ; there are 2 buttons
MouseOnButton = 0 ; mouse is neither on any button...
ButtonMouseOn = ; ...nor is any button in the down position
MidClick = 0 ; mouse button is not in the down position
LoadCustomFonts() ; loads custom fonts from "misc" folder
Gui, Default: Font, cWhite s%Text28% bold, %Text27% ; sets font type and size for main text, set by language
Gui, Default: Add, Text, x10 y12 w290 +BackgroundTrans, %Text8% ; "Log Off Windows" main text
Gui, Default: Font, s%Text30% bold, %Text29% ; sets font type and size for buttons
Gui, Default: Add, Text, x0 y120 w205 +BackgroundTrans Center, %Text9% ; adds "Switch User" text
Gui, Default: Add, Text, x110 y120 w210 +BackgroundTrans Center, %Text10% ; adds "Log Off" text
Loop, 3
GuiControl, Default: Hide, Btn%A_Index%Hvr ; hides all 3 "hover-state" button images
Loop, 3
GuiControl, Default: Hide, Btn%A_Index%Dwn ; hides all 3 "down-state" button images
SysGet, MainMonitorNumber, MonitorPrimary ; gets primary monitor id
SysGet, MainMonitor, Monitor, %MainMonitorNumber% ; gets dimensions of primary monitor
Yposition := Round(MainMonitorBottom / 4) ; divides height by 4 to get Y position of main GUI
; -----------------------------------------------------------------------------------------------------------------------------------------|
TransAmount = 0
Gui, BubbleWindow: new ; creates new GUI to work on, BubbleWindow
Gui, BubbleWindow: +LastFound -Caption +ToolWindow +AlwaysOnTop +E0x20 ; no titlebar or taskbar button, topmost and click-through
Gui, BubbleWindow: Color, 0x008000 ; sets BubbleWindow background color something unique
WinSet, TransColor, 0x008000 %TransAmount% ; sets transparent color the same as unique GUI color
Gui, BubbleWindow: Show, y%Yposition% w800 h285 NoActivate, BubbleWindow ; shows bubble-tip window without activating it
; -----------------------------------------------------------------------------------------------------------------------------------------|
Gui, BubbleWindow: Add, Picture, x324 y114 w322 h-1 +BackgroundTrans vMyPic1 Hidden, images\%Text22%.png ; bubble image 1
Gui, BubbleWindow: Font, s%Text31% bold, %Text29% ; bold font
Gui, BubbleWindow: Add, Text, x334 y146 w302 +BackgroundTrans vMyText1 Hidden, %Text9% ; "Switch User" bubble text title
Gui, BubbleWindow: Font, s%Text31% norm, %Text29% ; normal font
Gui, BubbleWindow: Add, Text, x334 y176 w302 r6 +BackgroundTrans vMyText2 Hidden, %Text11% ; "Switch User" bubble text description
; -----------------------------------------------------------------------------------------------------------------------------------------|
Gui, BubbleWindow: Add, Picture, x439 y114 w322 h-1 +BackgroundTrans vMyPic2 Hidden, images\%Text23%.png ; bubble image 2
Gui, BubbleWindow: Font, s%Text31% bold, %Text29% ; bold font
Gui, BubbleWindow: Add, Text, x449 y146 w302 +BackgroundTrans vMyText3 Hidden, %Text10% ; "Log Off" bubble text title
Gui, BubbleWindow: Font, s%Text31% norm, %Text29% ; normal font
Gui, BubbleWindow: Add, Text, x449 y176 w302 r6 +BackgroundTrans vMyText4 Hidden, %Text12% ; "Log Off" bubble text description
; -----------------------------------------------------------------------------------------------------------------------------------------|
Gui, Default: -Caption +ToolWindow +AlwaysOnTop ; no titlebar, no taskbar button, always on top
Gui, Default: Show, y%Yposition% w315 h200, LogoffWindow ; distance from top, calculated earlier
Gui, Default: Font, norm ; changes to normal-size black font for Cancel button
Gui, Default: Add, Button, x225 y170 w78 h21 gCancel vCancelButton, %Text13% ; adds Cancel button
XpArrowPointer() ; loads XP arrow pointer
if DesktopChange = 1 ; if "Desktop FX" is "Yes"...
{
Run, misc\fade.exe,, UseErrorLevel ; applies "fade to grey" effect as seperate process
if (ErrorLevel="ERROR") ; if "misc\face.exe" is not compiled
{
MsgBox, misc\fade.exe was not found.`nPlease compile misc\fade.ahk ; msgbox reminds user (AHK) to compile it
ExitApp ; exits before menu appears
}
}
OnMessage(0x200, "MouseMove") ; detects when mouse is moved
OnMessage(0x201, "MouseLDown") ; detects when left mouse button is clicked down
OnMessage(0x202, "MouseLUp") ; detects when left mouse button is released
SetTimer, CheckHoverDesktop, 50 ; checks if mouse over desktop 20 times per second
return
CheckHoverDesktop: ; checks if the mouse is over program window or desktop.
MouseGetPos,,,, hwnd ; gets mouse position
if DesktopChange = 1 ; if "Desktop FX" option is set to "Yes"...
{
if (hwnd = "Button1") or (hwnd = "Static1") or (hwnd = "Static3") or (hwnd = "Static4") or (hwnd = "Static5") or (hwnd = "Static6") or (hwnd = "Static7") or (hwnd = "Static8") or (hwnd = "Static9") or (hwnd = "Static10") or (hwnd = "Static11")
gosub, TurnOffHotkeys ; enables keys and mouse clicks if mouse is in any of above controls
else
gosub, TurnOnHotkeys ; disables keys and mouse clicks, makes "ding" sound instead
}
return
TurnOffHotkeys: ; enables keys and mouse clicks
Hotkeys = LButton|MButton|RButton|XButton1|XButton2|WheelUp|WheelDown|LWin|RWin|Tab|Space|Enter|Control|Alt|!Tab|^+Tab
Loop, Parse, Hotkeys, | ; uses pipe delimiter "|" as separator
Hotkey, %A_LoopField%,, Off ; key mapping suspended, so the above keys and buttons operate normally
return
TurnOnHotkeys: ; disables keys and mouse clicks, makes "ding" sound instead
Hotkeys = LButton|MButton|RButton|XButton1|XButton2|WheelUp|WheelDown|LWin|RWin|Tab|Space|Enter|Control|Alt|!Tab|^+Tab
Loop, Parse, Hotkeys, | ; uses pipe delimiter "|" as separator
Hotkey, %A_LoopField%, ding, On ; plays ding sound instead of regular key functions
return
ding:
SoundPlay, misc\ding.wav ; plays ding sound when mouse clicks out of window
return
S:: ; original XP shortcut for Switch User
Btn1_up: ; mouse-up event on button 1
Run, rundll32.exe user32.dll LockWorkStation ; command for switch user
ExitApp ; exits script
L:: ; original XP shortcut for Log Off
Btn2_up: ; mouse-up event on button 2
Shutdown, 0 ; command for log off
ExitApp ; exits script
C:: ; original XP shortcut for Cancel
!F4:: ; ALT+F4 by itself will not work correctly
Esc:: ; escape key
Cancel: ; "Cancel" button
OnExitCommand: ; everything below runs if script exits by any means
Process, Close, fade.exe
RemoveCustomPointers() ; removes custom pointers
RemoveCustomFonts() ; removes custom fonts
ExitApp ; exits script
HideBubbleWindow:
XpArrowPointer() ; sets XP arrow cursor
Loop, 2
GuiControl, BubbleWindow: Hide, MyPic%A_Index% ; hides bubble text windows
Loop, 4
GuiControl, BubbleWindow: Hide, MyText%A_Index% ; hides text controls
return
Nothing: ; does nothing but fakes a gLabel for button images
return
MakeTrans:
Loop
{
MouseGetPos,,, ControlID ; gets name of control under mouse
WinGetTitle, WindowTitle, ahk_id %ControlID% ; gets title of window under mouse
if (hwnd = "Static1") or (hwnd = "Static2") or (hwnd = "Static9") or (hwnd = "Static10") or (hwnd = "Static11") or (hwnd = "Button1") or !(WindowTitle = "LogoffWindow")
{
GuiControl, Hide, BubbleWindow
GuiControl, Default: -Redraw, %ButtonMouseOn%Dwn ; prevents redrawing button until it is loaded
GuiControl, Default: -Redraw, %ButtonMouseOn%Hvr ; prevents redrawing button until it is loaded
GuiControl, Default: +Redraw, %ButtonMouseOn% ; redraws button
MouseOnButton = 0 ; mouse is neither on any GUI button...
ButtonMouseOn = ; ...nor is any GUI button in the down position
MidClick = 0 ; mouse button is not in the down position
break ; breaks out of main loop
}
if A_Index = 1 ; if first instance of loop
Sleep, 400 ; initial delay is applied
TransAmount += 30 ; increases opacity level by 30, range available is 0 to 255
If(TransAmount > 255) ; when the increments of 30 surpass 255 (full opacity)
TransAmount = 255 ; opacity is set to 255 (full opacity)
WinSet, TransColor, 0x008000 %TransAmount%, BubbleWindow ; applies to GUI here in %TransAmount%
GuiControl, BubbleWindow: Show, MyPic%BubbleNumber% ; shows picture control with applied transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble window always on top
if(BubbleNumber=1) ; if bubble window 1 is the chosen window
{
GuiControl, BubbleWindow: Show, MyText1 ; shows "Switch User" bubble window title text
GuiControl, BubbleWindow: Show, MyText2 ; shows "Switch User" bubble window description text
}
if(BubbleNumber=2) ; if bubble window 2 is the chosen window
{
GuiControl, BubbleWindow: Show, MyText3 ; shows "Log Off" bubble window title text
GuiControl, BubbleWindow: Show, MyText4 ; shows "Log Off" bubble window description text
}
if (hwnd = "Static3") or (hwnd = "Static4") or (hwnd = "Static5") ; if mouse pointer is over "Switch User" button 1
{
GuiControl, BubbleWindow: Hide, MyPic2 ; hides bubble-tip image 2
GuiControl, BubbleWindow: Hide, MyText3 ; hides bubble-tip title text 2
GuiControl, BubbleWindow: Hide, MyText4 ; hides bubble-tip description text 2
}
if (hwnd = "Static6") or (hwnd = "Static7") or (hwnd = "Static8") ; if mouse pointer is over "Log Off" button 2
{
GuiControl, BubbleWindow: Hide, MyPic1 ; hides bubble-tip image 1
GuiControl, BubbleWindow: Hide, MyText1 ; hides bubble-tip title text 1
GuiControl, BubbleWindow: Hide, MyText2 ; hides bubble-tip description text 1
}
if(TransAmount = 255) ; if full opacity is reached
{
TransAmount = 0 ; opacity is set back to 0 for next round
break ; breaks out of loop
}
sleep, 30 ; fade-in time increments between loops
}
return
MouseMove(wParam, lParam, msg, hwnd) ; mouse-over images
{
global
Loop, %ButtonCount%
{
if MouseOnButton = 0
{
if (hwnd = Btn1_HWND) ; mouse-over image button 1
{
XpHandPointer() ; changes cursor to XP hand pointer
MouseOnButton = 1 ; changes this to "yes"
ButtonMouseOn = Btn1 ; mouse is over button 1
GuiControl, Default: -Redraw, Btn1 ; hides "button 1 down" image
GuiControl, Default: -Redraw, Btn1Dwn ; hides "button 1 down" image
GuiControl, Default: +Redraw, Btn1Hvr ; shows "button 1 default" image
BubbleNumber = 1 ; designates bubble-tip window number
if FadeInTips = 1 ; if fade-in bubble-tips is "yes"
gosub, MakeTrans ; makes them fade in
else ; if fade-in bubble-tips is "no"
{
WinSet, TransColor, 0x008000, BubbleWindow ; applies transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble-text GUI on top of main GUI
GuiControl, BubbleWindow: Show, MyPic1 ; shows picture control 1
GuiControl, BubbleWindow: Show, MyText1 ; shows text control 1
GuiControl, BubbleWindow: Show, MyText2 ; shows text control 2
}
break
}
if (hwnd = Btn2_HWND) ; mouse-over image button 2
{
XpHandPointer() ; changes cursor to XP hand pointer
MouseOnButton = 1 ; changes this to "yes"
ButtonMouseOn = Btn2 ; mouse is over button 2
GuiControl, Default: -Redraw, Btn2 ; hides "button 2 down" image
GuiControl, Default: -Redraw, Btn2Dwn ; hides "button 2 down" image
GuiControl, Default: +Redraw, Btn2Hvr ; shows "button 2 default" image
BubbleNumber = 2 ; designates bubble-tip window number
if FadeInTips = 1 ; if fade-in bubble-tips is "yes"
gosub, MakeTrans ; makes them fade in
else ; if fade-in bubble-tips is "no"
{
WinSet, TransColor, 0x008000, BubbleWindow ; applies transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble-text GUI on top of main GUI
GuiControl, BubbleWindow: Show, MyPic2 ; shows picture control 2
GuiControl, BubbleWindow: Show, MyText3 ; shows text control 3
GuiControl, BubbleWindow: Show, MyText4 ; shows text control 4
}
break
}
gosub, HideBubbleWindow ; hides bubble-tip window
}
}
if (hwnd != %ButtonMouseOn%_HWND) and (hwnd != %ButtonMouseOn%Hvr_HWND) and (hwnd != %ButtonMouseOn%Dwn_HWND) and (hwnd != LogoffWindow) ; not over buttons or window
{
gosub, HideBubbleWindow ; hides bubble-tip window
GuiControl, Default: -Redraw, %ButtonMouseOn%Dwn ; hides "button down" image
GuiControl, Default: -Redraw, %ButtonMouseOn%Hvr ; hides "button hover" image
GuiControl, Default: +Redraw, %ButtonMouseOn% ; redraws button
MouseOnButton = 0 ; mouse is neither on any GUI button...
ButtonMouseOn = ; ...nor is any GUI button in the down position
MidClick = 0 ; mouse button is not in the down position
}
}
return
Code: Select all
#SingleInstance, force ; forces new instance of script
#Persistent ; keeps script active
#NoTrayIcon ; hides tray icon
SetBatchLines, -1 ; runs at full speed
SetWorkingDir %A_ScriptDir% ; sets script directory as working directory
OnExit, OnExitCommand ; if script exits by any method, OnExitCommand subroutine is run
#Include, misc\functions.ahk ; gets shared program functions
Process, Close, XP_Logoff.exe ; terminates this 64-bit process
Process, Close, XP_Settings.exe ; terminates this 64-bit process
IniRead, Language, misc\options.ini, MainOptions, Language, English ; gets chosen language, "English" if error
IniRead, DesktopChange, misc\options.ini, MainOptions, DesktopChange, 0 ; gets "change desktop" information, "No" if error
IniRead, FadeInTips, misc\options.ini, MainOptions, FadeInTips, 0 ; gets "fade-in bubble-tips" information, "No" if error
if DesktopChange = 1 ; if "Desktop FX" is "Yes"...
gosub, TurnOnHotkeys
Loop, 37 ; reads INI file for all keys' contents
{
IniRead, Text%A_Index%, misc\options.ini, %Language%, key%A_Index% ; reads each key under chosen language and assigns to variable
StringReplace, Text%A_Index%, Text%A_Index%, ||, `n, All ; replaces pipe-delimiters with line breaks for accuracy
}
Gui, Default: New
Gui, Default: Color, black ; GUI background color, makes 1px black border effect
Gui, Default: Add, Picture, x1 y1 w313 h198, images\Bitmap20142.png ; exact PNG copy of Windows background BMP image
Gui, Default: Add, Picture, x266 y2 w48 h40, images\Bitmap20141.png ; exact PNG copy of Windows logo BMP image
AddGraphicBtn("x52","y82","h32","w32","Btn1","images\Standby.png","images\StandbyHover.png","images\StandByDown.png") ; loads all 3 states of "Stand By" button
AddGraphicBtn("x142","y82","h32","w32","Btn2","images\TurnOff.png","images\TurnOffHover.png","images\TurnOffDown.png") ; loads all 3 states of "Turn Off" button
AddGraphicBtn("x233","y82","h32","w32","Btn3","images\Restart.png","images\RestartHover.png","images\RestartDown.png") ; loads all 3 states of "Restart" button
ButtonCount = 3 ; there are 3 buttons
MouseOnButton = 0 ; mouse is neither on any GUI button...
ButtonMouseOn = ; ...nor is any GUI button in the down position
MidClick = 0 ; mouse button is not in the down position
LoadCustomFonts() ; loads custom fonts from "misc" folder
Gui, Default: Font, cWhite s%Text28% bold, %Text27% ; sets font type and size for main text, set by language
Gui, Default: Add, Text, x10 y12 w290 +BackgroundTrans, %Text1% ; "Shut down computer" main text
Gui, Default: Font, s%Text30% bold, %Text29% ; sets font type and size for buttons
Gui, Default: Add, Text, x0 y120 w138 +BackgroundTrans Center vStandByText, %Text2% ; adds "Stand By" text initially, changes to "Hibernate" when Shift key held down
Gui, Default: Add, Text, x0 y120 w315 +BackgroundTrans Center, %Text3% ; adds "Turn Off" text
Gui, Default: Add, Text, x182 y120 w133 +BackgroundTrans Center, %Text4% ; adds "Restart" text
Loop, 3
GuiControl, Default: Hide, Btn%A_Index%Hvr ; hides all 3 "hover-state" buttons
Loop, 3
GuiControl, Default: Hide, Btn%A_Index%Dwn ; hides all 3 "down-state" buttons
SysGet, MainMonitorNumber, MonitorPrimary ; gets primary monitor id
SysGet, MainMonitor, Monitor, %MainMonitorNumber% ; gets dimensions of primary monitor
Yposition := Round(MainMonitorBottom / 4) ; divides height by 4 to get Y position of main GUI
; ---Bubble-tip main hidden GUI------------------------------------------------------------------------------------------------------------|
TransAmount = 0
Gui, BubbleWindow: new ; creates new GUI to work on, BubbleWindow
Gui, BubbleWindow: +LastFound -Caption +ToolWindow +AlwaysOnTop +E0x20 ; no titlebar or taskbar button, topmost and click-through
Gui, BubbleWindow: Color, 0x008000 ; sets BubbleWindow background color something unique
WinSet, TransColor, 0x008000 %TransAmount% ; sets transparent color the same as unique GUI color
Gui, BubbleWindow: Show, y%Yposition% w800 h255 NoActivate, BubbleWindow ; shows bubble-tip window without activating it
; ---Bubble-tip window 1-------------------------------------------------------------------------------------------------------------------|
Gui, BubbleWindow: Add, Picture, x293 y114 w322 h-1 +BackgroundTrans vMyPic1 Hidden, images\%Text19%.png ; bubble image 1
Gui, BubbleWindow: Font, s%Text31% bold, %Text29% ; bold font
Gui, BubbleWindow: Add, Text, x303 y146 w302 +BackgroundTrans vMyText1 Hidden, %Text2% ; "Stand By" bubble text title
Gui, BubbleWindow: Font, s%Text31% norm, %Text29% ; normal font
Gui, BubbleWindow: Add, Text, x303 y176 w302 r6 +BackgroundTrans vMyText2 Hidden, %Text5% ; "Stand By" bubble text description
; ---Bubble-tip window 2-------------------------------------------------------------------------------------------------------------------|
Gui, BubbleWindow: Add, Picture, x383 y114 w322 h-1 +BackgroundTrans vMyPic2 Hidden, images\%Text20%.png ; bubble image 2
Gui, BubbleWindow: Font, s%Text31% bold, %Text29% ; bold font
Gui, BubbleWindow: Add, Text, x393 y146 w302 +BackgroundTrans vMyText3 Hidden, %Text3% ; "Turn Off" bubble text title
Gui, BubbleWindow: Font, s%Text31% norm, %Text29% ; normal font
Gui, BubbleWindow: Add, Text, x393 y176 w302 r6 +BackgroundTrans vMyText4 Hidden, %Text6% ; "Turn Off" bubble text description
; ---Bubble-tip window 3-------------------------------------------------------------------------------------------------------------------|
Gui, BubbleWindow: Add, Picture, x474 y114 w322 h-1 +BackgroundTrans vMyPic3 Hidden, images\%Text21%.png ; bubble image 3
Gui, BubbleWindow: Font, s%Text31% bold, %Text29% ; bold font
Gui, BubbleWindow: Add, Text, x484 y146 w300 +BackgroundTrans vMyText5 Hidden, %Text4% ; "Restart" bubble text
Gui, BubbleWindow: Font, s%Text31% norm, %Text29% ; normal font
Gui, BubbleWindow: Add, Text, x484 y176 w302 r6 +BackgroundTrans vMyText6 Hidden, %Text7% ; "Restart" bubble text description
; ---"Shutdown with updates available"-----------------------------------------------------------------------------------------------------|
Gui, Default: Add, Picture, x1 y157 w313 h-1 vUpdatesBkg Hidden, images\Bitmap20142updates.png ; blue PNG background image
Gui, Default: Add, Picture, x5 y168 w16 h-1 vUpdatesIcon +BackgroundTrans Hidden, images\ShutdownUpdates.png ; smaller instance of icon
Gui, Default: Font, cWhite s%Text31% norm, %Text29% ; sets correct font color and size
Gui, Default: Add, Text, x25 y168 w266 +BackgroundTrans vNonLinkText Hidden, %Text34% ; not underlined text
Gui, Default: Add, Text, x25 y168 +BackgroundTrans vSpacing Hidden, %Text35% ; spaces to place following line at correct location
Gui, Default: Font, cWhite s%Text31% underline, %Text29% ; underlining applied to font
Gui, Default: Add, Text, x+0 y168 +BackgroundTrans gShutdownNoUpdates vNoUpdateLink1 Hidden, %Text36% ; first line of second sentence (underlined link)
Gui, Default: Add, Text, x25 y+0 +BackgroundTrans gShutdownNoUpdates vNoUpdateLink2 Hidden, %Text37% ; second line of second sentence (underlined link)
; -----------------------------------------------------------------------------------------------------------------------------------------|
Gui, Default: -Caption +ToolWindow +AlwaysOnTop ; no titlebar, no taskbar button, always on top
Gui, Default: Show, y%Yposition% w315 h200, ShutdownWindow ; distance from top was calculated earlier
Gui, Default: Font, norm ; changes to normal-size black font for Cancel button
Gui, Default: Add, Button, x225 y170 w78 h21 gCancel vCancelButton, %Text13% ; adds Cancel button
XpArrowPointer() ; loads XP arrow pointer
if DesktopChange = 1 ; if "Desktop FX" is "Yes"...
{ ; disables keys and mouse clicks, makes "ding" sound instead
Run, misc\fade.exe,, UseErrorLevel ; applies "fade to grey" effect as seperate process
if (ErrorLevel="ERROR") ; if "misc\face.exe" is not compiled
{
MsgBox, misc\fade.exe was not found.`nPlease compile misc\fade.ahk ; msgbox reminds user (AHK) to compile it
ExitApp ; exits before menu appears
}
}
LargeIconYposition := (Yposition +188) ; finds new y-position for overlay icon
Gui, IconImage: New ; new window, not picture control, for "always on top" focus purposes
Gui, IconImage: Color, 0x008000 ; sets BubbleWindow background color something unique
Gui, IconImage: Add, Picture, x31 y2 w22 h-1 vOverlayIcon +BackgroundTrans Hidden, images\ShutdownUpdates.png ; icon image, placed but hidden
Gui, IconImage: +LastFound -Caption +ToolWindow +E0x20 +AlwaysOnTop ; no titlebar or taskbar button, topmost and click-through
WinSet, TransColor, 0x008000 255 ; sets transparent color the same as unique GUI color
Gui, IconImage: Show, y%LargeIconYposition% w52 ; shows the overlay icon image window with icon hidden
OnMessage(0x200, "MouseMove") ; detects when mouse is moved
OnMessage(0x201, "MouseLDown") ; detects when left mouse button is clicked down
OnMessage(0x202, "MouseLUp") ; detects when left mouse button is released
SetTimer, CheckHoverDesktop, 50 ; checks if mouse over desktop 20 times per second
return
~Shift:: ; maps SHIFT keys to "Stand By" button for alternate "Hibernate" functionality
GuiControl, Default:, StandByText, %Text32% ; changes to "Hibernate" text
GuiControl, BubbleWindow:, MyText1, %Text32% ; change bubble-tip title text to "Hibernate" also
GuiControl, BubbleWindow:, MyText2, %Text33% ; change bubble-tip description text
KeyWait, Shift ; waits for SHIFT key to be released
Guicontrol, Default:, StandByText, %Text2% ; changes back to "Stand By" text
GuiControl, BubbleWindow:, MyText1, %Text2% ; change bubble-tip title text to "Stand By" also
GuiControl, BubbleWindow:, MyText2, %Text5% ; change bubble-tip description text
return
~Control:: ; maps CONTROL keys to toggle "Shutdown with updates" extension menu
PreventRepeating() ; stops CONTROL from repeating and toggling the menu unnecessarily while held down
Toggle := !Toggle ; hotkey state modifier, alternates 1 or 0 on each press
if (Toggle = 1) ; if CONTROL is pressed
{
GuiControl, Default: Show, UpdatesBkg ; shows blue background PNG
GuiControl, Default: Move, CancelButton, y240 ; moves "Cancel" button to new position on new background
GuiControl, Default: Show, UpdatesIcon ; shows smaller instance of icon
GuiControl, Default: Show, NonLinkText ; shows first sentence of text, not underlined
GuiControl, Default: Show, Spacing ; shows spaces to place following line at correct location
GuiControl, Default: Show, NoUpdateLink1 ; shows first line of second sentence (underlined)
GuiControl, Default: Show, NoUpdateLink2 ; shows second line of second sentence (underlined)
Gui, Default: Show, h270, ShutdownWindow ; shows extended background in main GUI
Gui, IconImage: Show ; shows the overlay icon window this way to prevent flicker
GuiControl, IconImage: +Redraw, OverlayIcon ; larger instance of icon (over "Turn Off" button)
GuiControl, Default: +Redraw, CancelButton ; redraws the "Cancel" button this way to ensure it gets top z-order
Gui, BubbleWindow: +AlwaysOnTop ; if bubble-tip is active, it needs to stay on top or lose z-order
}
else ; if CONTROL is pressed again
{
GuiControl, Default: Hide, UpdatesBkg ; hides blue background PNG
GuiControl, Default: Move, CancelButton, y170 ; moves "Cancel" button back to original position in main GUI
GuiControl, Default: Hide, UpdatesIcon ; hides smaller instance of icon
GuiControl, Default: Hide, NonLinkText ; hides first sentence, not underlined
GuiControl, Default: Hide, Spacing ; hides spaces to place following line at correct location
GuiControl, Default: Hide, NoUpdateLink1 ; hides first line of second sentence (underlined)
GuiControl, Default: Hide, NoUpdateLink2 ; hides second line of second sentence (underlined)
Gui, Default: Show, h200, ShutdownWindow ; restores main GUI's height
Gui, IconImage: Hide ; hides the overlay icon window this way to prevent flicker
GuiControl, Default: +Redraw, CancelButton ; redraws the "Cancel" button this way to ensure it gets top z-order
Gui, BubbleWindow: +AlwaysOnTop ; if bubble-tip is active, it needs to stay on top or lose z-order
}
return
CheckHoverDesktop: ; check if the mouse is over program window or desktop.
MouseGetPos,,,, hwnd ; gets mouse position
if DesktopChange = 1 ; if "Desktop FX" option is "Yes"...
{
if (hwnd = "Button1") or (hwnd = "Static1") or (hwnd = "Static3") or (hwnd = "Static4") or (hwnd = "Static5") or (hwnd = "Static6") or (hwnd = "Static7") or (hwnd = "Static8") or (hwnd = "Static9") or (hwnd = "Static10") or (hwnd = "Static11") or (hwnd = "Static12") or (hwnd = "Static13") or (hwnd = "Static14") or (hwnd = "Static15") or (hwnd = "Static16") or (hwnd = "Static17") or (hwnd = "Static18") or (hwnd = "Static19") or (hwnd = "Static20") or (hwnd = "Static21")
gosub, TurnOffHotkeys ; enables keys and mouse clicks if mouse is in any of above controls
else
gosub, TurnOnHotkeys ; disables keys and mouse clicks, makes "ding" sound instead
}
return
TurnOffHotkeys: ; enables keys and mouse clicks
Hotkeys = LButton|MButton|RButton|XButton1|XButton2|WheelUp|WheelDown|LWin|RWin|Tab|Space|Enter|Alt|!Tab|^+Tab
Loop, Parse, Hotkeys, | ; uses pipe delimiter "|" as separator
Hotkey, %A_LoopField%,, Off ; key mapping suspended, so the above keys and buttons operate normally
return
TurnOnHotkeys: ; disables keys and mouse clicks, makes "ding" sound instead
Hotkeys = LButton|MButton|RButton|XButton1|XButton2|WheelUp|WheelDown|LWin|RWin|Tab|Space|Enter|Alt|!Tab|^+Tab
Loop, Parse, Hotkeys, | ; uses pipe delimiter "|" as separator
Hotkey, %A_LoopField%, ding, On ; plays ding sound instead of regular key functions
return
ding:
SoundPlay, misc\ding.wav ; plays ding sound whn mouse clicks out of window
return
Btn1_up: ; mouse-up event on button 1
gosub, HideBubbleWindow ; hides bubble-tip windows
ControlGetText, StandbyOrHibernate, Static13 ; gets either "Stand By" or "Hibernate" text from Static 13 control
if StandbyOrHibernate = %Text2% ; if text is "Stand By"
DllCall("PowrProf\SetSuspendState", "int", 0, "int", 1, "int", 0) ; command for Stand By (sleep)
if StandbyOrHibernate = %Text32% ; if text is "Hibernate"
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0) ; command for Hibernate
ExitApp ; exits script
U:: ; original XP shortcut for shut down
Btn2_up: ; mouse-up event on button 2
ControlGet, OpenWindowsUpdates, Visible,, Static19 ; checks if Static19 text control ("Click here to turn off without installing updates") is visible
if OpenWindowsUpdates = 1 ; if 1 (true)...
Run, ms-settings:windowsupdate-action ; opens Windows Update in Settings
if OpenWindowsUpdates = 0 ; if 0 (false)...
Shutdown, 1 ; shuts down computer
ExitApp ; exits script
ShutdownNoUpdates: ; action for "Click here to turn off without installing updates"
SoundPlay, misc\click.wav
Shutdown, 1 ; shuts down computer
ExitApp ; exits script
R:: ; original XP shortcut for restart
Btn3_up: ; mouse-up event on button 3
Shutdown, 2 ; restarts computer
ExitApp ; exits script
C:: ; original XP shortcut for Cancel
!F4:: ; ALT+F4 by itself will not work correctly
Esc:: ; escape key
Cancel: ; "Cancel" button
OnExitCommand: ; everything below runs if script exits by any means
Process, Close, fade.exe
RemoveCustomPointers() ; removes custom pointers
RemoveCustomFonts() ; removes custom fonts
ExitApp ; exits script
HideBubbleWindow:
XpArrowPointer() ; sets XP arrow cursor
Loop, 3
GuiControl, BubbleWindow: Hide, MyPic%A_Index% ; hides bubble text windows
Loop, 6
GuiControl, BubbleWindow: Hide, MyText%A_Index% ; hides text controls
return
Nothing: ; does nothing but fakes a gLabel for button images
return
MakeTrans:
Loop
{
MouseGetPos,,, ControlID ; gets name of control under mouse
WinGetTitle, WindowTitle, ahk_id %ControlID% ; gets title of window under mouse
if (hwnd = "Static1") or (hwnd = "Static2") or (hwnd = "Static12") or (hwnd = "Static13") or (hwnd = "Static14") or (hwnd = "Static15") or (hwnd = "Static16") or (hwnd = "Static17") or (hwnd = "Static18") or (hwnd = "Static19") or (hwnd = "Static20") or (hwnd = "Static21") or (hwnd = "Button1") or !(WindowTitle = "ShutdownWindow")
{
GuiControl, Hide, BubbleWindow ; hides bubble tip window
GuiControl, Default: -Redraw, %ButtonMouseOn%Dwn ; prevents redrawing button until it is loaded
GuiControl, Default: -Redraw, %ButtonMouseOn%Hvr ; prevents redrawing button until it is loaded
GuiControl, Default: +Redraw, %ButtonMouseOn% ; redraws button
MouseOnButton = 0 ; mouse is neither on any GUI button...
ButtonMouseOn = ; ...nor is any GUI button in the down position
MidClick = 0 ; mouse button is not in the down position
break ; breaks out of main loop
}
if A_Index = 1 ; if first instance of loop
Sleep, 400 ; initial delay is applied
TransAmount += 30 ; increases opacity level by 30, range available is 0 to 255
if(TransAmount > 255) ; when the increments of 30 surpass 255 (full opacity)
TransAmount = 255 ; opacity is set to 255 (full opacity)
WinSet, TransColor, 0x008000 %TransAmount%, BubbleWindow ; applies to GUI here in %TransAmount%
GuiControl, BubbleWindow: Show, MyPic%BubbleNumber% ; shows picture control with applied transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble window always on top
if(BubbleNumber=1) ; if bubble window 1 is the chosen window
{
GuiControl, BubbleWindow: Show, MyText1 ; shows "Stand By" bubble window title text
GuiControl, BubbleWindow: Show, MyText2 ; shows "Stand By" bubble window description text
}
if(BubbleNumber=2) ; if bubble window 2 is the chosen window
{
GuiControl, BubbleWindow: Show, MyText3 ; shows "Turn Off" bubble window title text
GuiControl, BubbleWindow: Show, MyText4 ; shows "Turn Off" bubble window description text
}
if(BubbleNumber=3) ; if bubble window 3 is the chosen window
{
GuiControl, BubbleWindow: Show, MyText5 ; shows "Restart" bubble window title text
GuiControl, BubbleWindow: Show, MyText6 ; shows "Restart" bubble window description text
}
if (hwnd = "Static3") or (hwnd = "Static4") or (hwnd = "Static5") ; if mouse pointer is over "Stand By" button 1
{
GuiControl, BubbleWindow: Hide, MyPic2 ; hides bubble-tip image 2
GuiControl, BubbleWindow: Hide, MyText3 ; hides bubble-tip title text 2
GuiControl, BubbleWindow: Hide, MyText4 ; hides bubble-tip description text 2
GuiControl, BubbleWindow: Hide, MyPic3 ; hides bubble-tip image 3
GuiControl, BubbleWindow: Hide, MyText5 ; hides bubble-tip title text 3
GuiControl, BubbleWindow: Hide, MyText6 ; hides bubble-tip description text 3
}
if (hwnd = "Static6") or (hwnd = "Static7") or (hwnd = "Static8") ; if mouse pointer is over "Turn Off" button 2
{
GuiControl, BubbleWindow: Hide, MyPic1 ; hides bubble-tip image 1
GuiControl, BubbleWindow: Hide, MyText1 ; hides bubble-tip title text 1
GuiControl, BubbleWindow: Hide, MyText2 ; hides bubble-tip description text 1
GuiControl, BubbleWindow: Hide, MyPic3 ; hides bubble-tip image 3
GuiControl, BubbleWindow: Hide, MyText5 ; hides bubble-tip title text 3
GuiControl, BubbleWindow: Hide, MyText6 ; hides bubble-tip description text 3
}
if (hwnd = "Static9") or (hwnd = "Static10") or (hwnd = "Static11") ; if mouse pointer is over "Restart" button 3
{
GuiControl, BubbleWindow: Hide, MyPic1 ; hides bubble-tip image 1
GuiControl, BubbleWindow: Hide, MyText1 ; hides bubble-tip title text 1
GuiControl, BubbleWindow: Hide, MyText2 ; hides bubble-tip description text 1
GuiControl, BubbleWindow: Hide, MyPic2 ; hides bubble-tip image 2
GuiControl, BubbleWindow: Hide, MyText3 ; hides bubble-tip title text 2
GuiControl, BubbleWindow: Hide, MyText4 ; hides bubble-tip description text 2
}
if(TransAmount = 255) ; if full opacity is reached
{
TransAmount = 0 ; opacity is set back to 0 for next round
break ; breaks out of loop
}
sleep, 30 ; fade-in time increments between loops
}
return
MouseMove(wParam, lParam, msg, hwnd) ; mouse-over images
{
global
Loop, %ButtonCount%
{
if MouseOnButton = 0
{
if (hwnd = Btn1_HWND) ; mouse-over image button 1
{
XpHandPointer() ; changes cursor to XP hand pointer
MouseOnButton = 1 ; changes this to "yes"
ButtonMouseOn = Btn1 ; mouse is over button 1
GuiControl, Default: -Redraw, Btn1 ; hides "button 1 down" image
GuiControl, Default: -Redraw, Btn1Dwn ; hides "button 1 down" image
GuiControl, Default: +Redraw, Btn1Hvr ; shows "button 1 default" image
BubbleNumber = 1 ; designates bubble-tip window number
if FadeInTips = 1 ; if fade-in bubble-tips is "yes"
gosub, MakeTrans ; makes them fade in
else ; if fade-in bubble-tips is "no"
{
WinSet, TransColor, 0x008000, BubbleWindow ; applies transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble-text GUI on top of main GUI
GuiControl, BubbleWindow: Show, MyPic1 ; shows picture control 1
GuiControl, BubbleWindow: Show, MyText1 ; shows text control 1
GuiControl, BubbleWindow: Show, MyText2 ; shows text control 2
}
break
}
if (hwnd = Btn2_HWND) ; mouse-over image button 2
{
XpHandPointer() ; changes cursor to XP hand pointer
MouseOnButton = 1 ; changes this to "yes"
ButtonMouseOn = Btn2 ; mouse is over button 2
GuiControl, Default: -Redraw, Btn2 ; hides "button 2 down" image
GuiControl, Default: -Redraw, Btn2Dwn ; hides "button 2 down" image
GuiControl, Default: +Redraw, Btn2Hvr ; shows "button 2 default" image
BubbleNumber = 2 ; designates bubble-tip window number
if FadeInTips = 1 ; if fade-in bubble-tips is "yes"
gosub, MakeTrans ; makes them fade in
else ; if fade-in bubble-tips is "no"
{
WinSet, TransColor, 0x008000, BubbleWindow ; applies transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble-text GUI on top of main GUI
GuiControl, BubbleWindow: Show, MyPic2 ; shows picture control 2
GuiControl, BubbleWindow: Show, MyText3 ; shows text control 3
GuiControl, BubbleWindow: Show, MyText4 ; shows text control 4
}
break
}
if (hwnd = Btn3_HWND) ; mouse-over image button 3 (does not apply to Logoff window, only Shutdown)
{
XpHandPointer() ; changes cursor to XP hand pointer
MouseOnButton = 1 ; changes this to "yes"
ButtonMouseOn = Btn3 ; mouse is over button 3
GuiControl, Default: -Redraw, Btn3 ; hides "button 3 down" image
GuiControl, Default: -Redraw, Btn3Dwn ; hides "button 3 down" image
GuiControl, Default: +Redraw, Btn3Hvr ; shows "button 3 default" image
BubbleNumber = 3 ; designates bubble-tip window number
if FadeInTips = 1 ; if fade-in bubble-tips is "yes"
gosub, MakeTrans ; makes them fade in
else ; if fade-in bubble-tips is "no"
{
WinSet, TransColor, 0x008000, BubbleWindow ; applies transparency
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble-text GUI on top of main GUI
GuiControl, BubbleWindow: Show, MyPic3 ; shows picture control 3
GuiControl, BubbleWindow: Show, MyText5 ; shows text control 5
GuiControl, BubbleWindow: Show, MyText6 ; shows text control 6
}
break
}
gosub, HideBubbleWindow ; hides bubble-tip window
}
}
if (hwnd != %ButtonMouseOn%_HWND) and (hwnd != %ButtonMouseOn%Hvr_HWND) and (hwnd != %ButtonMouseOn%Dwn_HWND) and (hwnd != ShutdownWindow) ; not over buttons or window
{
gosub, HideBubbleWindow ; hides bubble-tip window
GuiControl, Default: -Redraw, %ButtonMouseOn%Dwn ; hides "button down" image
GuiControl, Default: -Redraw, %ButtonMouseOn%Hvr ; hides "button hover" image
GuiControl, Default: +Redraw, %ButtonMouseOn% ; redraws button
MouseOnButton = 0 ; mouse is neither on any GUI button...
ButtonMouseOn = ; ...nor is any GUI button in the down position
MidClick = 0 ; mouse button is not in the down position
}
}
return
Code: Select all
CurrentBuildDate = January 11, 2021 ; current date which displays in About msgbox
#SingleInstance, force ; forces new instance of script
#Persistent ; keeps script active
#NoTrayIcon ; hides tray icon
SetWorkingDir %A_ScriptDir% ; sets script directory as working directory
OnExit, OnExitCommand ; if script exits by any method, OnExitCommand subroutine is run
#Include, misc\functions.ahk ; gets shared program functions
Process, Close, XP_Shutdown.exe ; terminates this 64-bit process
Process, Close, XP_Logoff.exe ; terminates this 64-bit process
IniRead, Language, misc\options.ini, MainOptions, Language, English ; gets chosen language, "English" if error
IniRead, DesktopChange, misc\options.ini, MainOptions, DesktopChange, 0 ; gets "change desktop" information, "No" if error
IniRead, FadeInTips, misc\options.ini, MainOptions, FadeInTips, 0 ; gets "fade-in bubble-tips" information, "No" if error
gosub, PopulateTexts ; assigns variable contents to each control's text (Text14 to Text18)
Gui, Color, black ; behind gui background image, makes 1px black border
Gui, Add, Picture, x1 y1 w313 h198, images\Bitmap20142.png ; exact PNG copy of Windows background BMP image
Gui, Add, Picture, x266 y2 w48 h40, images\Bitmap20141.png ; exact PNG copy of Windows logo BMP image
Gui, Font, cWhite s14 bold, Microsoft Sans Serif ; white size 14 bold Microsoft Sans Serif font
Gui, Add, Text, x10 y12 w290 +BackgroundTrans vOptionsText, %Text14% ; adds white "Options" text in chosen language
Gui, Font, s9 Bold ; size 10 bold font
Gui, Add, Text, x0 y50 w165 +BackgroundTrans Right vLanguageChoice, %Text15%`: ; adds "choose language" menu
Gui, Font ; clears font back to default
Gui, Add, DropDownList, x170 y50 w100 Choose%Text24% gChangeLanguage vLanguage, Afrikaans|Albanian|Amharic|Arabic|Armenian|Azerbaijani|Basque|Belarusian|Bengali|Bosnian|Bulgarian|Catalan|Cebuano|Chichewa|Chinese|Corsican|Croatian|Czech|Danish|Dutch|English|Esperanto|Estonian|Filipino|Finnish|French|Frisian|Galician|Georgian|German|Greek|Gujarati|Haitian|Hausa|Hawaiian|Hebrew|Hindi|Hmong|Hungarian|Icelandic|Igbo|Indonesian|Irish|Italian|Japanese|Javanese|Kannada|Kazakh|Khmer|Kinyarwanda|Klingon|Korean|Kurdish|Kyrgyz|Lao|Latin|Latvian|Lithuanian|Luxembourgish|Macedonian|Malagasy|Malay|Malayalam|Maltese|Maori|Marathi|Mongolian|Myanmar|Nepali|Norwegian|Odia|Pashto|Persian|Polish|Portugese|Punjabi|Romanian|Russian|Samoan|ScotsGaelic|Serbian|Sesotho|Shona|Sindhi|Sinhala|Slovak|Slovenian|Somali|Spanish|Sundanese|Swahili|Swedish|Tajik|Tamil|Tatar|Telugu|Thai|Turkish|Turkmen|Ukrainian|Urdu|Uyghur|Uzbek|Vietnamese|Welsh|Xhosa|Yiddish|Yoruba|Zulu
Gui, Font, s9 Bold cWhite ; size 9 bold font
Gui, Add, Text, x0 y70 w165 +BackgroundTrans Right vDesktopFxChoice, %Text16%`: ; adds "Desktop FX" checkbox text
Gui, Add, Checkbox, x170 y70 w12 h12 gClick vDesktopChange Checked%DesktopChange% ; adds "Desktop FX" checkbox
Gui, Add, Text, x0 y90 w165 +BackgroundTrans Right vTooltipFxChoice, %Text17%`: ; adds "Tooltip FX" checkbox text
Gui, Add, Checkbox, x170 y90 w12 h12 gClick vFadeInTips Checked%FadeInTips% ; adds "Tooltip FX" checkbox
Gui, Font ; clears font back to default
Gui, Add, Button, x12 y173 w20 h21 gAbout, `? ; adds "About" button
Gui, Add, Button, x224 y173 w84 h21 gSave Default vSaveText, %Text18% ; adds Save button, makes default so "enter" triggers it
Gui, Font, s9 Bold ; size 9 bold font
Gui, Add, Text, cWhite x50 y165 w170 h21 +BackgroundTrans vWebsiteLink, %Text26%`:
Gui, Font, Underline ; size 9 bold underlined
Gui, Add, Text, cWhite x50 y180 w170 h21 +BackgroundTrans gLink, www.weedtrek.ca
SysGet, MainMonitorNumber, MonitorPrimary ; gets primary monitor id
SysGet, MainMonitor, Monitor, %MainMonitorNumber% ; gets dimensions of primary monitor
Yposition := Round(MainMonitorBottom / 4) ; divides height by 4 to get Y position
Gui, +AlwaysOnTop +ToolWindow ; always on top unless Weed Trek link is clicked
SoundPlay, misc\pop.wav ; plays pop sound
Gui, Show, y%Yposition% w315 h200, %Text25% ; uses calculated "y" height and selected language in title
XpArrowPointer() ; loads XP arrow pointer
return
ChangeLanguage:
Gui, Submit, NoHide ; submits contents of all controls for instant change
SoundPlay, misc\click.wav ; plays click sound
gosub, PopulateTexts ; assigns variable contents to each control's text (Text14 to Text18)
GuiControl,, OptionsText, %Text14% ; "Options" text
GuiControl,, LanguageChoice, %Text15%`: ; "Language" text
GuiControl,, DesktopFxChoice, %Text16%`: ; "Desktop FX" text
GuiControl,, TooltipFxChoice, %Text17%`: ; "Tooltip FX" text
GuiControl,, SaveText, %Text18% ; "Save" button text
GuiControl,, Text24, %Language%`: ; menu position number for initial display in dropdown menu
GuiControl,, WebsiteLink, %Text26%`: ; "My Website" text
Gui, Show,, %Text25% ; "Window Title" text
return
PopulateTexts:
Loop, 33 ; reads INI file for keys' contents
{
IniRead, Text%A_Index%, misc\options.ini, %Language%, key%A_Index% ; reads each key under chosen language and assigns to variable
StringReplace, Text%A_Index%, Text%A_Index%, ||, `n, All ; replaces pipe-delimiters with line breaks (for accuracy if included)
}
return
About:
Gui, +OwnDialogs ; MsgBox won't hide behind window
SoundPlay, misc\click.wav ; plays click sound
Loop, read, misc\info.txt ; reads information text file in "misc" folder
LastLine := A_LoopReadLine ; finds last line of text file
StringLeft, VersionNumber, LastLine, 6 ; extracts first 6 characters of last line
MsgBox, 4,, XP Shutdown and Logoff`nby Aaron Bewza`n`nVersion`: %VersionNumber%`n%CurrentBuildDate%`n`nOpen history text file`? ; prompt to open history text file
IfMsgBox Yes ; if yes...
{
SoundPlay, misc\click.wav ; plays click sound
Gui, -AlwaysOnTop ; removes "always on top" status from main GUI and msgbox so text file can be unobscured
Run, misc\info.txt ; history text file is opened
}
IfMsgBox No ; if no...
SoundPlay, misc\click.wav ; plays click sound and msgbox closes
return
Save:
Gui, Submit ; submits contents of all controls
SoundPlay, misc\click.wav, Wait ; plays click sound
IniWrite, %Language%, misc\options.ini, MainOptions, Language ; stores language settings
IniWrite, %DesktopChange%, misc\options.ini, MainOptions, DesktopChange ; stores desktop effects settings
IniWrite, %FadeInTips%, misc\options.ini, MainOptions, FadeInTips ; stores bubble-tip effects settings
ExitApp ; exits menu
Link:
Run, http://weedtrek.ca ; opens Weed Trek official site
Gui, -AlwaysOnTop ; removes "AlwaysOnTop" status from GUI so it doesn't interfere with website
SoundPlay, misc\click.wav, Wait ; plays click sound
Return
!F4:: ; ALT+F4 by itself will not work correctly
Esc:: ; escape key
Cancel: ; cancel button
GuiClose: ; if script is closed with the toolwindow "x"
SoundPlay, misc\click.wav, Wait ; plays click sound
OnExitCommand: ; everything below runs if script exits by any means
RemoveCustomPointers() ; restores system default pointers
ExitApp ; exits script
Click:
SoundPlay, misc\click.wav, Wait ; plays click sound
return
MakeTrans: ; fake subroutines to avoid errors while loading "misc\functions.ahk"...
HideBubbleWindow: ; ...as Logoff and Shutdown only use it for bubble tip windows
return
Code: Select all
#SingleInstance, force
#NoTrayIcon
if WinExist("LogoffWindow") or WinExist("ShutdownWindow")
{
hBM := FsGrayscale(X,Y,,,W,H)
hFG := DllCall("CreateBitmap","Int",1,"Int",1,"Int",1,"Int",32,"PtrP",0x10000000,"Ptr") ; 0x79000000 was original
Gui, Bkg: New, +ToolWindow -Caption +E0x8000000 hwndBackgroundBitmap ; +LastFound +AlwaysOnTop interfered
Gui, Bkg: Margin, 0, 0 ; no margins
Gui, Bkg: Add, Picture,, HBITMAP:%hBM% ; adds original greyscale bitmap of background?
Gui, Bkg: Add, Picture,xp yp wp hp BackgroundTrans, HBITMAP:%hFG% ; adds the one which I presume fades?
Gui, Bkg: Show, x%X% y%Y% w%W% h%H% Hide, BackgroundBitmap ; initially hidden
DllCall("AnimateWindow", "Ptr", BackgroundBitmap, "Int", 4000, "Int", 0xA0000) ; 4000ms fade time matches XP but cannot use menu during fade
}
else
ExitApp
return
FsGrayscale(ByRef X1:=0, ByRef Y1:=0, ByRef X2:=0, ByRef Y2:=0, ByRef W:=0, ByRef H:=0) ; makes greyscale screenshot
{
Local
VarSetCapacity(WININFO,62), NumPut(62,WININFO,"Int"), PW:=&WININFO
DllCall("GetWindowInfo", "Ptr",hWnd:=DllCall("GetDesktopWindow", "Ptr"), "Ptr",&WININFO)
Loop, Parse, % "X1.Y1.X2.Y2.W.H",.
%A_LoopField% := (A_Index<5 ? NumGet(PW+0,A_Index*4,"Int") : A_Index=5 ? X2-X1 : Y2-Y1)
tBM := DllCall("CopyImage", "Ptr"
, DllCall( "CreateBitmap", "Int",1, "Int",1, "Int",0x1, "Int",8, "Ptr",0, "Ptr")
, "Int",0, "Int",W, "Int",H, "Int",0x2008, "Ptr")
tDC := DllCall("CreateCompatibleDC", "Ptr",0, "Ptr")
DllCall("DeleteObject", "Ptr",DllCall("SelectObject", "Ptr",tDC, "Ptr",tBM, "Ptr"))
Loop % (255, n:=0x000000, VarSetCapacity(RGBQUAD256,256*4,0))
Numput(n+=0x010101, RGBQUAD256, A_Index*4, "Int")
DllCall("SetDIBColorTable", "Ptr",tDC, "Int",0, "Int",256, "Ptr",&RGBQUAD256)
sDC := DllCall("GetDC", "Ptr",hWnd, "Ptr")
DllCall("BitBlt", "Ptr",tDC, "Int",0, "Int",0, "Int",W, "Int",H
, "Ptr",sDC, "Int",X1, "Int",Y1, "Int",0x00CC0020)
Return (tBM, DllCall("ReleaseDC", "Ptr",hWnd, "Ptr",sDC), DllCall("DeleteDC", "Ptr",tDC))
}
return
Code: Select all
; functions
XpArrowPointer() ; calls XP arrow pointer
{
XpArrowPointer := DllCall("LoadCursorFromFile", Str, A_ScriptDir "\images\Cursor_1.cur")
DllCall("SetSystemCursor", Uint, XpArrowPointer, Int, 32512) ; applies as default
}
XpHandPointer() ; calls XP hand pointer
{
XpHandPointer := DllCall("LoadCursorFromFile", Str, A_ScriptDir "\images\Cursor_15.cur")
DllCall("SetSystemCursor", Uint, XpHandPointer, Int, 32512) ; applies as default only while over certain controls
}
RemoveCustomPointers() ; change to default arrow/hand pointers
{
DllCall("SystemParametersInfo", UInt, 0x57, UInt, 0, UInt, 0, UInt, 0)
}
LoadCustomFonts() ; adds temporary fonts from "misc" folder
{
DllCall("GDI32.DLL\AddFontResourceEx", Str, A_ScriptDir "\misc\XpTahoma.ttf", UInt, (FR_PRIVATE:=0x10), Int, 0) ; XpTahoma.ttf
DllCall("GDI32.DLL\AddFontResourceEx", Str, A_ScriptDir "\misc\Klingon.ttf", UInt, (FR_PRIVATE:=0x10), Int, 0) ; Klingon.ttf
}
RemoveCustomFonts() ; removes temporary fonts
{
DllCall("GDI32.DLL\RemoveFontResourceEx",Str, A_ScriptDir "\misc\XPtahoma.ttf", UInt, (FR_PRIVATE:=0x10), Int, 0) ; XpTahoma.ttf
DllCall("GDI32.DLL\AddFontResourceEx", Str, A_ScriptDir "\misc\Klingon.ttf", UInt, (FR_PRIVATE:=0x10), Int, 0) ; Klingon.ttf
}
AddGraphicBtn(Btn_X, Btn_Y, Btn_H, Btn_W, Btn_Identifier, Btn_Up, Btn_Hvr, Btn_Dwn) ; add image buttons
{
global
Gui, Default: Add, Picture
, +AltSubmit +BackgroundTrans %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Hvr hwnd%Btn_Identifier%Hvr_hwnd
, %Btn_Hvr% ; hover-state image
Gui, Default: Add, Picture
, +AltSubmit +BackgroundTrans %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Dwn hwnd%Btn_Identifier%Dwn_hwnd
, %Btn_Dwn% ; down-state image
Gui, Default: Add, Picture
, +AltSubmit +BackgroundTrans %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier% hwnd%Btn_Identifier%_hwnd
, %Btn_Up% ; default-state image
return
}
MouseLDown(wParam, lParam, msg, hwnd) ; mouse-down on images
{
global
MidClick = 1 ; mouse button is in process of clicking down
if (hwnd = %ButtonMouseOn%Hvr_HWND) ; if mouse is over a button's hover-image
{
Gui, BubbleWindow: +AlwaysOnTop ; sets bubble texts to be on top of main GUI
GuiControl, Default: -Redraw, %ButtonMouseOn%Hvr ; hover-state button remains underneath
GuiControl, Default: -Redraw, %ButtonMouseOn% ; default-state button remains underneath
GuiControl, Default: +Redraw, %ButtonMouseOn%Dwn ; down-state button is redrawm
}
MidClick = 0 ; mouse button is not clicking down
GetKeyState, MouseLBtnState, LButton, P ; detects state of mouse button
if MouseLBtnState = U ; if mouse button up, click has not completed
MouseLUp("", "", "", %hwnd%) ; does not register the click
Gui, IconImage: +AlwaysOnTop ; if bubble-tip window is active, it needs to stay on top or lose focus
return
}
MouseLUp(wParam, lParam, msg, hwnd) ; mouse-up on images
{
global
MidClick = 1 ; if mouse button is in process of clicking down
if (hwnd = %ButtonMouseOn%Dwn_HWND) ; if mouse is over a button's down-image
gosub, %ButtonMouseOn%_Up ; runs subroutine associated with chosen button on mouse-up
MidClick = 0 ; mouse button is not clicking down
return
}
PreventRepeating() ; stops CONTROL from repeating and flickering the "Shutdown w/Updates" window
{
Static PrevRep := Object()
if PrevRep[A_ThisHotkey]
Exit
if InStr(A_ThisHotkey,"Up")
{
PrevRep[SubStr(A_ThisHotkey,1,-3)] := False
Exit
}
PrevRep[A_ThisHotkey] := True
Hotkey, %A_ThisHotkey%%A_Space%Up,%A_ThisHotkey%
}
Code: Select all
XP Shutdown and Logoff
Aaron Bewza
www.weedtrek.ca
- select main options and language settings by opening "XP_Options"
- press CONTROL to toggle "XP Shutdown w/Updates" feature in "XP_Shutdown" (almost complete)
- press and hold SHIFT to see "Hibernate" button in "XP_Shutdown"
Version History:
(Alpha)
September 2020:
v0.900 built basic menu, it was enough, so I stopped working on it
November 2020:
v0.910 when asked to, I added rough version of hover bubble text
v0.911 fine-tuned bubble-text windows, less flickering but still buggy
December 2020:
v0.912 using higher resolution bubbles made by Enger
v0.913 solved flicker on bubble-text windows, thanks mikeyww
v0.914 now using real XP buttons, thanks Millenashea for finding them
v0.915 made Log Off GUI and INI file for options to simplify things
v0.916 made Settings GUI to interact with INI file
v0.920 supports 5 languages, Millenashea made correct Japanese
v0.921 supports 12 languages, centered all texts under buttons
v0.930 supports 108 languages, also translates bubble-tip texts
v0.931 fixed Bliss wallpaper from being applied on program exit
v0.932 optimized folders, hopefully fixed bubble-tip positions
v0.933 added realtime language changes for in the options menu
(Beta)
v0.940 added background fade thanks to SKAN
v0.941 used math to align buttons correctly on both menus
v0.942 added actual XP arrow and hand pointer cursors
v0.943 included an XP Tahoma font (no install), works
v0.944 tried to match original XP texts on both main dialogs
v0.945 styled balloon-tip bubble sizes and texts to match XP
v0.946 disabled XP Tahoma font if Japanese language chosen
v0.947 fixed pointer/bubble tips locking while mouse over desktop
v0.948 moved most functions into "misc\functions.ahk"
v0.949 added "less width" bubble-tip images for short one-liners
V0.950 fixed XP pointer sticking on, added line breaks in bubble-tips
v0.951 fixed some minor errors, cleaned up and added more comments
v0.952 fixed ESC mapping so it works correctly while in window
v0.953 removed some "click" sounds, more accurate to original XP
v0.954 added some rough shadows under bubble-tip windows
v0.955 background fade now happens underneath main window, buggy
v0.956 somewhat fixed background fade integration but not 100%
v0.957 fixed button "flicker" using guicontrol +-redraw
v0.958 adjusted some bubble-tip images' heights to match XP
v0.959 replaced 2 dropdowns with checkboxes for "yes/no" choices
v0.960 moved stuff to options.ini to standardize language variables
v0.961 wrapped INI key contents in quotation marks for reliability
v0.962 added Klingon.ttf font to properly display Klingon (English)
v0.963 customize font-type and font-size per chosen language in INI
v0.964 replaced "Stand By" bubble-tip with correct text (had Hibernate text)
v0.965 added shift-key trigger for "Hibernate" button and its bubble text
v0.966 added Arabic to languages, not sure why I didn't see it before
v0.967 added "shutdown w/updates" feature (press CONTROL to activate)
January 2021:
v0.968 fixed z-order issue with overlay icon and bubble-tip windows
v0.969 fixed underline height issue in custom XpTahoma font
v0.970 "shutdown w/updates" opens Windows Updates, fixed Cancel button not showing
v0.971 fixed underlined text not lining up with other text, applied to all languages
v0.972 moved fade into its own EXE, allows ESC and menu buttons while fading
v0.973 disabled fade.exe/fade.ahk from being accidentally run independently