XP Luna Shutdown Dialog for Windows 10

Post your working scripts, libraries and tools
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

XP Luna Shutdown Dialog for Windows 10

17 Sep 2020, 20:24

I'm aaronbewza from the pre-2013 site, and this is
XP Shutdown/Logoff Menu for Windows 10 x64 (v0.973 beta) :happybday:

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)
Xp_Shutdown_ahk.zip
Package with AHK scripts, no EXEs
(342.04 KiB) Downloaded 3 times
Here is the download page with the compiled x64 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
dialog1.jpg
XP Luna Shutdown Dialog screenshot
dialog1.jpg (152.13 KiB) Viewed 500 times
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
Here is the code for "XP_Shutdown":

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
Here is the code for "XP_Settings":

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
Here is the code for "fade" (thanks very much SKAN) :

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
Here is the code for "functions":

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%
}
And my history.txt:

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
Last edited by WeedTrek on 13 Jan 2021, 06:59, edited 15 times in total.
gwarble
Posts: 469
Joined: 30 Sep 2013, 15:01

Re: XP Luna Shutdown Dialog

17 Sep 2020, 21:35

very cool, can i ask why?

unless things have changed since 7, look for a file TranscodedWallpaper.jpg that you can backup and restore

or try the second post in this thread:
https://autohotkey.com/board/topic/82794-gdi-grayscalebitmap-converts-gdi-bitmap-to-greyscale/
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

Re: XP Luna Shutdown Dialog

17 Sep 2020, 23:30

Thanks for the suggestion :) I tried all that (I do all the homework / trial and error that I can before I ask for help), but since it's way deep in AppData windows folder, it doesn't let me do that. I also tried fullscreen screengrabs then greyscaling the results, then using FFMPEG to blur it in 6 stages... the problem was the flicker, and that with a Windows display zoom of 250% my fullscreen image was 250% the size of the screen. That plus the flicker caused me to rethink that route.
Why? I'm on Windows 10 and I loved XP ever since 2001 and next year it will be 20 years old. I think it's awesome people are creating Luna skins and start menus, for me it's a passion project.
My first music studio PC was in 2003, my grandmother bought it for me at a time in my life when I got off drugs and was recording music again.
I want to honor her memory with that same case but modern hardware so I can use it again in the studio. It had XP and I'm currently putting a Gen3 Threadripper in it and I'd like it to look original to what it used to be. It is something I can do (and use) to honor her memory as she's been gone since 2013.

But yah the solution for the desktop images is in the original description, same script without the parts that mess with the desktop.
My Weed Trek video archive: http://weedtrek.ca
gwarble
Posts: 469
Joined: 30 Sep 2013, 15:01

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 00:17

thanks for the detailed explanation, sounds like a great reason to me (and i love passion projects especially with nostalgia)

in my screensaver I'm able to read that file without issue and without admin rights, which should mean you can copy it to a temp folder where you have write access and then reset it later with SetWallpaper()?

I agree flicker is an annoying and pretty constant battle, particularly with ahk gui commands, but using GDI+ or just plain GDI can achieve great results, the script in SKAN's #2 post runs flicker free on my old win7 machine, I'll try it on win10 machines tomorrow
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 01:44

Yes I know the file you're talking about, it's a dynamically changing file which is a copy of the chosen desktop image. It's located here:
C:\Users\NetPig\AppData\Roaming\Microsoft\Windows\Themes\TranscodedWallpaper (no file ext)
Screenshot 2020-09-17 233829.jpg
Location of TranscodedWallpaper (no ext)
Screenshot 2020-09-17 233829.jpg (53.33 KiB) Viewed 368 times
...but it's a JPG without any file extension on it. It was impossible for me to copy or rename it, so I gave up. This might be different than the filename and behavior you described because of different Windows 10 versions?
I'll look into GDI because I could also use the flicker-free approach to the three buttons on the menu... I'll test it as well, thanks very much.
*EDIT* the script you referred me to worked very smoothly on Windows 10, but with all the calls and the dynamic BMP creation I simply don't understand what's going on there. He's a pro who's on another level entirely :shock:
My Weed Trek video archive: http://weedtrek.ca
User avatar
SKAN
Posts: 853
Joined: 29 Sep 2013, 16:58

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 04:22

WeedTrek wrote:the script you referred me to worked very smoothly on Windows 10
Thanks for the confirmation. I will rewrite GDI_GrayscaleBitmap() with x64 support.
While at it, I will also try my own vista+ version. Thanks for the inspiration.
WeedTrek wrote:but with all the calls and the dynamic BMP creation I simply don't understand what's going on there. He's a pro who's on another level entirely :shock:
If you need any help regarding this, post in ask-for-help forum and [mention] me. :thumbup:
gwarble
Posts: 469
Joined: 30 Sep 2013, 15:01

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 08:22

good point, he’s definitely on another level (thanks for everything SKAN)

for the buttons i would recommend looking into class ImageButton for the most aesthetically pleasing results
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 15:14

Thanks very much, I'll definitely do that! You'll hear from me soon on the help thread.
This may be unrelated, and not sure the right place to add this, but I came up with this, using FFMPEG and one of Sean's functions.
It shrinks a fullscreen screenshot to w1280, applies greyscaling, then puts 6 stages of blur on it in a folder named "test". I think the "stages to greyscale" we've been talking about can be integrated with something like this to produce an enhanced effect of both color fading and blurring at the same time. Alternating back and forth between draining color and applying blur may work. I'll pound on this some more, and talk to you soon.
Here is what I have, remember put FFMPEG.EXE into A_ScriptDir.

Code: Select all

#SingleInstance, force
SetWorkingDir, %A_ScriptDir%

IfNotExist, test
	FileCreateDir, test

CaptureScreen(0, 0, A_ScriptDir "\test\color.jpg") ; takes fullscreen capture
RunWait, %comspec% /c ffmpeg.exe -y -i "%A_ScriptDir%\test\color.jpg" -vf scale=1280:-1 -q:v 1 "%A_ScriptDir%\test\color.jpg",, Hide	; uses FFMPEG to scale and change image quality
RunWait, %comspec% /c ffmpeg.exe -y -i "%A_ScriptDir%\test\color.jpg" -vf format=gray "%A_ScriptDir%\test\fade0.jpg",, Hide			; then greyscales it

Loop, 5
	Run, %comspec% /c ffmpeg.exe -y -i "%A_ScriptDir%\test\fade0.jpg" -vf smartblur=lr=%A_Index% "%A_ScriptDir%\test\fade%A_Index%.jpg",, Hide ; -vf smartblur=lr= (strength of blur 1 to 5)
FileDelete, test\temp.jpg ; deletes original fullscreen capture

ExitApp

Esc::
ExitApp

; function by Sean, sorry I don't have the link to the original thread:


/* CaptureScreen(aRect, bCursor, sFileTo, nQuality)
1) If the optional parameter bCursor is True, captures the cursor too.
2) If the optional parameter sFileTo is 0, set the image to Clipboard.
   If it is omitted or "", saves to screen.bmp in the script folder,
   otherwise to sFileTo which can be BMP/JPG/PNG/GIF/TIF.
3) The optional parameter nQuality is applicable only when sFileTo is JPG. Set it to the desired quality level of the resulting JPG, an integer between 0 - 100.
4) If aRect is 0/1/2/3, captures the entire desktop/active window/active client area/active monitor.
5) aRect can be comma delimited sequence of coordinates, e.g., "Left, Top, Right, Bottom" or "Left, Top, Right, Bottom, Width_Zoomed, Height_Zoomed".
   In this case, only that portion of the rectangle will be captured. Additionally, in the latter case, zoomed to the new width/height, Width_Zoomed/Height_Zoomed.

Example:
CaptureScreen(0)
CaptureScreen(1)
CaptureScreen(2)
CaptureScreen(3)
CaptureScreen("100, 100, 200, 200")
CaptureScreen("100, 100, 200, 200, 400, 400")   ; Zoomed
*/

/* Convert(sFileFr, sFileTo, nQuality)
Convert("C:\image.bmp", "C:\image.jpg")
Convert("C:\image.bmp", "C:\image.jpg", 95)
Convert(0, "C:\clip.png")   ; Save the bitmap in the clipboard to sFileTo if sFileFr is "" or 0.
*/


CaptureScreen(aRect = 0, bCursor = False, sFile = "JPG", nQuality = "10")
{
	If !aRect
	{
		SysGet, nL, 76  ; virtual screen left & top
		SysGet, nT, 77
		SysGet, nW, 78	; virtual screen width and height
		SysGet, nH, 79
	}
	Else If aRect = 1
		WinGetPos, nL, nT, nW, nH, A
	Else If aRect = 2
	{
		WinGet, hWnd, ID, A
		VarSetCapacity(rt, 16, 0)
		DllCall("GetClientRect" , "ptr", hWnd, "ptr", &rt)
		DllCall("ClientToScreen", "ptr", hWnd, "ptr", &rt)
		nL := NumGet(rt, 0, "int")
		nT := NumGet(rt, 4, "int")
		nW := NumGet(rt, 8)
		nH := NumGet(rt,12)
	}
	Else If aRect = 3
	{
		VarSetCapacity(mi, 40, 0)
		DllCall("GetCursorPos", "int64P", pt), NumPut(40,mi,0,"uint")
		DllCall("GetMonitorInfo", "ptr", DllCall("MonitorFromPoint", "int64", pt, "Uint", 2, "ptr"), "ptr", &mi)
		nL := NumGet(mi, 4, "int")
		nT := NumGet(mi, 8, "int")
		nW := NumGet(mi,12, "int") - nL
		nH := NumGet(mi,16, "int") - nT
	}
	Else
	{
		StringSplit, rt, aRect, `,, %A_Space%%A_Tab%
		nL := rt1	; convert the Left,top, right, bottom into left, top, width, height
		nT := rt2
		nW := rt3 - rt1
		nH := rt4 - rt2
		znW := rt5
		znH := rt6
	}

	mDC := DllCall("CreateCompatibleDC", "ptr", 0, "ptr")
	hBM := CreateDIBSection(mDC, nW, nH)
	oBM := DllCall("SelectObject", "ptr", mDC, "ptr", hBM, "ptr")
	hDC := DllCall("GetDC", "ptr", 0, "ptr")
	DllCall("BitBlt", "ptr", mDC, "int", 0, "int", 0, "int", nW, "int", nH, "ptr", hDC, "int", nL, "int", nT, "Uint", 0x40CC0020)
	DllCall("ReleaseDC", "ptr", 0, "ptr", hDC)
	If bCursor
		CaptureCursor(mDC, nL, nT)
	DllCall("SelectObject", "ptr", mDC, "ptr", oBM)
	DllCall("DeleteDC", "ptr", mDC)
	If znW && znH
		hBM := Zoomer(hBM, nW, nH, znW, znH)
	If sFile = 0
		SetClipboardData(hBM)
	Else Convert(hBM, sFile, nQuality), DllCall("DeleteObject", "ptr", hBM)
}

CaptureCursor(hDC, nL, nT)
{
	VarSetCapacity(mi, 32, 0), Numput(16+A_PtrSize, mi, 0, "uint")
	DllCall("GetCursorInfo", "ptr", &mi)
	bShow   := NumGet(mi, 4, "uint")
	hCursor := NumGet(mi, 8)
	xCursor := NumGet(mi,8+A_PtrSize, "int")
	yCursor := NumGet(mi,12+A_PtrSize, "int")

	DllCall("GetIconInfo", "ptr", hCursor, "ptr", &mi)
	xHotspot := NumGet(mi, 4, "uint")
	yHotspot := NumGet(mi, 8, "uint")
	hBMMask  := NumGet(mi,8+A_PtrSize)
	hBMColor := NumGet(mi,16+A_PtrSize)

	If bShow
		DllCall("DrawIcon", "ptr", hDC, "int", xCursor - xHotspot - nL, "int", yCursor - yHotspot - nT, "ptr", hCursor)
	If hBMMask
		DllCall("DeleteObject", "ptr", hBMMask)
	If hBMColor
		DllCall("DeleteObject", "ptr", hBMColor)
}

Zoomer(hBM, nW, nH, znW, znH)
{
	mDC1 := DllCall("CreateCompatibleDC", "ptr", 0, "ptr")
	mDC2 := DllCall("CreateCompatibleDC", "ptr", 0, "ptr")
	zhBM := CreateDIBSection(mDC2, znW, znH)
	oBM1 := DllCall("SelectObject", "ptr", mDC1, "ptr",  hBM, "ptr")
	oBM2 := DllCall("SelectObject", "ptr", mDC2, "ptr", zhBM, "ptr")
	DllCall("SetStretchBltMode", "ptr", mDC2, "int", 4)
	DllCall("StretchBlt", "ptr", mDC2, "int", 0, "int", 0, "int", znW, "int", znH, "ptr", mDC1, "int", 0, "int", 0, "int", nW, "int", nH, "Uint", 0x00CC0020)
	DllCall("SelectObject", "ptr", mDC1, "ptr", oBM1)
	DllCall("SelectObject", "ptr", mDC2, "ptr", oBM2)
	DllCall("DeleteDC", "ptr", mDC1)
	DllCall("DeleteDC", "ptr", mDC2)
	DllCall("DeleteObject", "ptr", hBM)
	Return zhBM
}

Convert(sFileFr = "", sFileTo = "", nQuality = "")
{
	If (sFileTo = "")
		sFileTo := A_ScriptDir . "\screen.bmp"
	SplitPath, sFileTo, , sDirTo, sExtTo, sNameTo
	
	If Not hGdiPlus := DllCall("LoadLibrary", "str", "gdiplus.dll", "ptr")
		Return	sFileFr+0 ? SaveHBITMAPToFile(sFileFr, sDirTo (sDirTo = "" ? "" : "\") sNameTo ".bmp") : ""
	VarSetCapacity(si, 16, 0), si := Chr(1)
	DllCall("gdiplus\GdiplusStartup", "UintP", pToken, "ptr", &si, "ptr", 0)

	If !sFileFr
	{
		DllCall("OpenClipboard", "ptr", 0)
		If	(DllCall("IsClipboardFormatAvailable", "Uint", 2) && (hBM:=DllCall("GetClipboardData", "Uint", 2, "ptr")))
			DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "ptr", hBM, "ptr", 0, "ptr*", pImage)
		DllCall("CloseClipboard")
	}
	Else If	sFileFr Is Integer
		DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "ptr", sFileFr, "ptr", 0, "ptr*", pImage)
	Else	DllCall("gdiplus\GdipLoadImageFromFile", "wstr", sFileFr, "ptr*", pImage)
	DllCall("gdiplus\GdipGetImageEncodersSize", "UintP", nCount, "UintP", nSize)
	VarSetCapacity(ci,nSize,0)
	DllCall("gdiplus\GdipGetImageEncoders", "Uint", nCount, "Uint", nSize, "ptr", &ci)
	struct_size := 48+7*A_PtrSize, offset := 32 + 3*A_PtrSize, pCodec := &ci - struct_size
	Loop, %	nCount
		If InStr(StrGet(Numget(offset + (pCodec+=struct_size)), "utf-16") , "." . sExtTo)
			break

	If (InStr(".JPG.JPEG.JPE.JFIF", "." . sExtTo) && nQuality<>"" && pImage && pCodec < &ci + nSize)
	{
		DllCall("gdiplus\GdipGetEncoderParameterListSize", "ptr", pImage, "ptr", pCodec, "UintP", nCount)
		VarSetCapacity(pi,nCount,0), struct_size := 24 + A_PtrSize
		DllCall("gdiplus\GdipGetEncoderParameterList", "ptr", pImage, "ptr", pCodec, "Uint", nCount, "ptr", &pi)
		Loop, %	NumGet(pi,0,"uint")
			If (NumGet(pi,struct_size*(A_Index-1)+16+A_PtrSize,"uint")=1 && NumGet(pi,struct_size*(A_Index-1)+20+A_PtrSize,"uint")=6)
			{
				pParam := &pi+struct_size*(A_Index-1)
				NumPut(nQuality,NumGet(NumPut(4,NumPut(1,pParam+0,"uint")+16+A_PtrSize,"uint")),"uint")
				Break
			}
	}

	If pImage
		pCodec < &ci + nSize	? DllCall("gdiplus\GdipSaveImageToFile", "ptr", pImage, "wstr", sFileTo, "ptr", pCodec, "ptr", pParam) : DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "ptr", pImage, "ptr*", hBitmap, "Uint", 0) . SetClipboardData(hBitmap), DllCall("gdiplus\GdipDisposeImage", "ptr", pImage)

	DllCall("gdiplus\GdiplusShutdown" , "Uint", pToken)
	DllCall("FreeLibrary", "ptr", hGdiPlus)
}


CreateDIBSection(hDC, nW, nH, bpp = 32, ByRef pBits = "")
{
	VarSetCapacity(bi, 40, 0)
	NumPut(40, bi, "uint")
	NumPut(nW, bi, 4, "int")
	NumPut(nH, bi, 8, "int")
	NumPut(bpp, NumPut(1, bi, 12, "UShort"), 0, "Ushort")
	Return DllCall("gdi32\CreateDIBSection", "ptr", hDC, "ptr", &bi, "Uint", 0, "UintP", pBits, "ptr", 0, "Uint", 0, "ptr")
}

SaveHBITMAPToFile(hBitmap, sFile)
{
	VarSetCapacity(oi,104,0)
	DllCall("GetObject", "ptr", hBitmap, "int", 64+5*A_PtrSize, "ptr", &oi)
	fObj := FileOpen(sFile, "w")
	fObj.WriteShort(0x4D42)
	fObj.WriteInt(54+NumGet(oi,36+2*A_PtrSize,"uint"))
	fObj.WriteInt64(54<<32)
	fObj.RawWrite(&oi + 16 + 2*A_PtrSize, 40)
	fObj.RawWrite(NumGet(oi, 16+A_PtrSize), NumGet(oi,36+2*A_PtrSize,"uint"))
	fObj.Close()
}

SetClipboardData(hBitmap)
{
	VarSetCapacity(oi,104,0)
	DllCall("GetObject", "ptr", hBitmap, "int", 64+5*A_PtrSize, "ptr", &oi)
	sz := NumGet(oi,36+2*A_PtrSize,"uint")
	hDIB :=	DllCall("GlobalAlloc", "Uint", 2, "Uptr", 40+sz, "ptr")
	pDIB := DllCall("GlobalLock", "ptr", hDIB, "ptr")
	DllCall("RtlMoveMemory", "ptr", pDIB, "ptr", &oi + 16 + 2*A_PtrSize, "Uptr", 40)
	DllCall("RtlMoveMemory", "ptr", pDIB+40, "ptr", NumGet(oi, 16+A_PtrSize), "Uptr", sz)
	DllCall("GlobalUnlock", "ptr", hDIB)
	DllCall("DeleteObject", "ptr", hBitmap)
	DllCall("OpenClipboard", "ptr", 0)
	DllCall("EmptyClipboard")
	DllCall("SetClipboardData", "Uint", 8, "ptr", hDIB)
	DllCall("CloseClipboard")
}
Last edited by WeedTrek on 18 Sep 2020, 16:10, edited 1 time in total.
My Weed Trek video archive: http://weedtrek.ca
User avatar
SKAN
Posts: 853
Joined: 29 Sep 2013, 16:58

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 15:20

WeedTrek wrote:I believe to be one of SKAN's functions (I had it on hand, looks like his code anyway, I'm horrible at labelling saved tidbits).
Not me, but Sean :)
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

Re: XP Luna Shutdown Dialog for Windows 10

18 Sep 2020, 16:08

HAha ok thanks I'll make the appropriate edits :D
My Weed Trek video archive: http://weedtrek.ca
User avatar
WeedTrek
Posts: 40
Joined: 22 Mar 2019, 14:29
Location: Cache Creek BC Canada
Contact:

Re: XP Luna Shutdown Dialog for Windows 10

12 Jan 2021, 18:36

bump! Beta release version is now available... check top post for changes :)
My Weed Trek video archive: http://weedtrek.ca

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 21 guests