XP Luna Shutdown Dialog for Windows 10

Post your working scripts, libraries and tools
User avatar
WeedTrek
Posts: 26
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 Luna Shutdown Dialog for Windows 10 :happybday:
It works 95% as it should. I'm on Windows 10 x64 v2004 :)
dialog1.jpg
XP Luna Shutdown Dialog screenshot
dialog1.jpg (152.13 KiB) Viewed 335 times
*WARNING* The first script (XP Luna Shutdown Dialog - bkg.ahk) changes the user's desktop background to the XP default desktop, and since I cannot figure out a way to back up the user's otherwise chosen Desktop Background "image" (in web folder down in appdata themes), it leaves the XP wallpaper in place and forces the user to manually choose their own again in Settings.
Please use the second script (XP Luna Shutdown Dialog - no bkg.ahk) if you don't want your dektop affected, I removed the part which messes with that.

Here is a short video of it in action, it quickly changes the desktop background through 11 images towards 100% greyscale. I know... fullscreen GUI no margins after screenshot bla bla but that was much too flickery of an approach, the transition between GuiControl image replacements was absolutely painful. Yes I tried -redraw and +redraw etc but no change. Double buffering didn't seem to like this script.
Anyway, Youtube link: [youtube]https://youtu.be/dnT5SJ9xUcI[/youtube]

And please, if you know of a solution to the desktop background "bug" please let me know :) it would be nice to let the user "revert" back to their chosen desktop.
Thanks very much to everyone I borrowed bits of code from lol you are all awesome, honored to be part of this site.

XP Luna Shutdown Dialog:
XpLunaShutdownDialog.zip
ZIP folder with both versions of script and all required image files
(1.38 MiB) Downloaded 12 times
Here is the code for first script (changes the desktop):

Code: Select all

#SingleInstance, force
#Persistent
#NoTrayIcon
SetWorkingDir %A_ScriptDir%

; Xp Luna Shutdown Dialog
; by Aaron Bewza, but thanks to the AHK community for letting me use pieces and tidbits of various stuff from throughout the years
; a recreation of the Windows XP Shutdown screen
; (yes I made a screenshot system which used FFMPEG to greyscale, resize and blur the resulting images...
; ...but GuiControl picture was not able to change through them all in fullscreen without massive flickering.

; WARNING! I had a problem trying to switch back to user's default chosen Desktop wallpaper image. 
; Please see subroutine BTN1_UP for more information on that. Unfortunately, I cannot figure out
; a way to copy or backup the existing Desktop background wallpaper for replacement once the
; menu is finished being used... therefore it reverts back to the XP Luna theme Desktop wallpaper.

SetTimer CheckHoverDesktop, 50 ; checks if mouse over desktop

WinMinimizeAll

ButtonCount = 3 ; sets starting parameters for these variables
MouseOnButton = 0
ButtonMouseOn = 
MidClick = 0

Gui, Add, Picture, w320 h-1 x1 y0 , backgrounds\bkg.png		; background image
AddGraphicBtn("x56", "y80", "h36", "w36", "Btn1", "buttons\Standby.jpg", "buttons\StandbyHover.jpg", "buttons\StandByDown.jpg") ; adds button images via function
AddGraphicBtn("x144", "y80", "h36", "w36", "Btn2", "buttons\TurnOff.jpg", "buttons\TurnOffHover.jpg", "buttons\TurnOffDown.jpg")
AddGraphicBtn("x232", "y80", "h36", "w36", "Btn3", "buttons\Restart.jpg", "buttons\RestartHover.jpg", "buttons\RestartDown.jpg")

Gui, Add, Button, x250 y173 w56 h18 gCancel, Cancel			; Cancel button
Gui, Font, s8
Gui, Add, Text, Center x10 y168 w230 r2 cWhite vTextArea 	; creates text area for button info
Gui, Color, 003298											; matches the dark blue top/bottom colors of gui background image

Gui, Margin, 1, 0
OnMessage(0x200, "MouseMove")
OnMessage(0x201, "MouseLDown")
OnMessage(0x202, "MouseLUp")
 SysGet, Height, 17						; gets height of monitor in pixels
 QuarterHeight := Height / 4
 Yposition := Round(QuarterHeight)		; rounds to single digit, no decimals
Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Show, y%Yposition%					; uses calculated screen height to determine distance from top

GuiControl, 1:Hide, Btn1Hvr				; hide the non-regular button images
GuiControl, 1:Hide, Btn2Hvr
GuiControl, 1:Hide, Btn3Hvr
GuiControl, 1:Hide, Btn1Dwn
GuiControl, 1:Hide, Btn2Dwn
GuiControl, 1:Hide, Btn3Dwn
WinGet, id, ID, A						; gets window ID

sleep 300								; simulates the XP delay before the fade

SetWallpaper(A_ScriptDir "\backgrounds\fade01.jpg")		; cycles through desktop background images (color to greyscale)
	sleep 200											; waits 1/5th of a second between changing images
SetWallpaper(A_ScriptDir "\backgrounds\fade02.jpg")		; please see BTN1_UP subroutine for more information about switching back to user's chosen desktop wallpaper.
	sleep 200											; I can't make "TranscodedWallpaper" show up as the one this program switches back to, even though it should.
SetWallpaper(A_ScriptDir "\backgrounds\fade03.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade04.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade05.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade06.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade07.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade08.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade09.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade10.jpg")
	sleep 200
SetWallpaper(A_ScriptDir "\backgrounds\fade11.jpg") ; final greyscale image which remains until button choices are used.
Return

CheckHoverDesktop: ; check if the mouse is over program window or desktop.
MouseGetPos,,, hwnd
WinExist("ahk_id " hwnd)
WinGet, detection, ProcessName	; assigns "detection" variable with window's ID under the mouse.
if detection = explorer.exe		; if mouse is over the desktop and not the program window.
{
	Hotkey, LButton, ding, On	; disables mouse/keyboard functions and makes it "ding" instead.
	Hotkey, MButton, ding, On
	Hotkey, RButton, ding, On
	Hotkey, XButton1, ding, On
	Hotkey, XButton2, ding, On
	Hotkey, WheelUp, ding, On
	Hotkey, WheelDown, ding, On
	Hotkey, LWin, ding, On
	Hotkey, RWin, ding, On
	Hotkey, Tab, ding, On
	Hotkey, Space, ding, On
	Hotkey, Enter, ding, On
	Hotkey, Control, ding, On
	Hotkey, Alt, ding, On
	Hotkey, Space, ding, On
	Hotkey, !Tab, ding, On
	Hotkey, ^+Tab, ding, On
}
if detection != explorer.exe	; if mouse is over program window and not the desktop
{
	MouseMove, %x%, %y% 
	Hotkey, LButton, ding, Off	; removes mouse/keyboard restrictions.
	Hotkey, MButton, ding, Off
	Hotkey, RButton, ding, Off
	Hotkey, XButton1, ding, Off
	Hotkey, XButton2, ding, Off
	Hotkey, WheelUp, ding, Off
	Hotkey, WheelDown, ding, Off
	Hotkey, LWin, ding, Off
	Hotkey, RWin, ding, Off
	Hotkey, Tab, ding, Off
	Hotkey, Space, ding, Off
	Hotkey, Enter, ding, Off
	Hotkey, Control, ding, Off
	Hotkey, Alt, ding, Off
	Hotkey, Space, ding, Off
	Hotkey, !Tab, ding, Off
	Hotkey, ^+Tab, ding, Off
}
return

Btn1_up: ; mouse-up event on button 1
SoundPlay, sounds\click.wav
SetWallpaper(A_ScriptDir "\backgrounds\original.jpg") ; sets included Xp Luna theme desktop bkg,
; I can't figure out how to preserve user's desktop image for reverting back to once the menu has been used.
; The path to the cached Desktop Background images in Windows 10 is:
; C:\Users\(USERNAME)\AppData\Roaming\Microsoft\Windows\Themes\

RestoreCursor() ; restores cursor to normal
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) ; command for sleep/stand by.
ExitApp
Return

Btn2_up: ; mouse-up event on button 2
SoundPlay, sounds\click.wav
SetWallpaper(A_ScriptDir "\backgrounds\original.jpg")
RestoreCursor()
  Shutdown, 9 ; shuts down computer
ExitApp
Return

Btn3_up: ; mouse-up event on button 3
SoundPlay, sounds\click.wav
SetWallpaper(A_ScriptDir "\backgrounds\original.jpg")
RestoreCursor()
  Shutdown, 2 ; restarts computer
ExitApp
Return

ding:
SoundPlay, sounds\ding.wav
return

Nothing:
Return

Esc::
Cancel:
SoundPlay, sounds\click.wav
SetWallpaper(A_ScriptDir "\backgrounds\original.jpg")
RestoreCursor()
WinMinimizeAllUndo ; restores minimized windows
ExitApp
return

; |-------------------------------------------------------------------------------------------------------|
; |--------------------------------------------- functions -----------------------------------------------|
; |-------------------------------------------------------------------------------------------------------|

SetWallpaper(ImgPath) ; sets wallpaper
{
	Return DllCall("SystemParametersInfo", UINT, 20, UINT, uiParam, STR, ImgPath, UINT, 2)
}

AddGraphicBtn(Btn_X, Btn_Y, Btn_H, Btn_W, Btn_Identifier, Btn_Up, Btn_Hvr, Btn_Dwn) ; add image buttons
{
	Global
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Hvr hwnd%Btn_Identifier%Hvr_hwnd, %Btn_Hvr%
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Dwn hwnd%Btn_Identifier%Dwn_hwnd, %Btn_Dwn%
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier% hwnd%Btn_Identifier%_hwnd, %Btn_Up%
}

MouseMove(wParam, lParam, msg, hwnd) ; mouse-over images
{
	Global
	Loop, %ButtonCount%
	{
		If MouseOnButton = 0
		{
			if (hwnd = Btn1_HWND) ; mouse-over image button 1
			{
				GuiControl, Hide, Btn1
				GuiControl, Hide, Btn1Dwn
				GuiControl, Show, Btn1Hvr ; shows button 1 hover image
				GuiControl, Text, TextArea, Stand By - Keeps your session in memory and`nputs the computer in a low-power state.
				MouseOnButton = 1
				ButtonMouseOn = Btn1
				SetCursor() ; sets cursor to hand pointer
				Break
			}
			if (hwnd = Btn2_HWND) ; mouse-over image button 2
			{
				GuiControl, Hide, Btn2
				GuiControl, Hide, Btn2Dwn				
				GuiControl, Show, Btn2Hvr ; shows button 2 hover image
				GuiControl, Text, TextArea, Turn Off - Shuts down Windows so you`ncan safely turn off the computer.
				MouseOnButton = 1
				ButtonMouseOn = Btn2
				SetCursor()
				Break
			}
			if (hwnd = Btn3_HWND) ; mouse-over image button 3
			{
				GuiControl, Hide, Btn3
				GuiControl, Hide, Btn3Dwn				
				GuiControl, Show, Btn3Hvr ; shows button 3 hover image
				GuiControl, Text, TextArea, Restart - Shuts down Windows and`nthen starts Windows again.
				MouseOnButton = 1
				ButtonMouseOn = Btn3
				SetCursor()
				Break
			}
			RestoreCursor() ; restores cursor to regular
		}
	}
	If (MouseOnButton = 1) and (hwnd = id) and (MidClick = 0) ; mouse is not over buttons, but still in window
	{
		GuiControl, Show, %ButtonMouseOn%
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Text, TextArea ; removes any text present in the control
		MouseOnButton = 0
		ButtonMouseOn = 
		RestoreCursor() ; restores cursor to regular
	}
	If (hwnd != %ButtonMouseOn%_HWND) and (hwnd != %ButtonMouseOn%Hvr_HWND) and (hwnd != %ButtonMouseOn%Dwn_HWND) and (hwnd != id) ; mouse is not over buttons OR window
	{
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Show, %ButtonMouseOn%
		GuiControl, Text, TextArea ; removes any text present in the control
		MouseOnButton = 0
		ButtonMouseOn = 
		RestoreCursor() ; restores cursor to regular once mouse is not over image
	}
	Return
}

MouseLDown(wParam, lParam, msg, hwnd) ; mouse-down on images
{
	Global
	MidClick = 1 ; prevents mousemove from presuming mouse is no longer over image
	If (hwnd = %ButtonMouseOn%Hvr_HWND)
	{
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Hide, %ButtonMouseOn%
		GuiControl, Show, %ButtonMouseOn%Dwn
	}
	MidClick = 0
	GetKeyState, MouseLBtnState, LButton, P
	If MouseLBtnState = U
		MouseLUp("", "", "", %hwnd%)
	Return
}

MouseLUp(wParam, lParam, msg, hwnd) ; mouse-up after clicking images
{
	Global
	MidClick = 1
	If (hwnd = %ButtonMouseOn%Dwn_HWND)
	{
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%
		GuiControl, Show, %ButtonMouseOn%Hvr
		GoSub % ButtonMouseOn . "_Up"
	}
	MidClick = 0
	Return
}

SetCursor() ; change cursor to pointer
{
    CursorHandle := DllCall("LoadImage", "Uint", 0, "Uint", 32649, "Uint", 2, "Uint", 0, "Uint", 0, "Uint", 0x8000)
    DllCall("SetSystemCursor", Uint, CursorHandle, Int, 32512)
}

RestoreCursor() ; restores cursor to normal
{
    DllCall("SystemParametersInfo", UInt, 0x57, UInt, 0, UInt, 0, UInt, 0)
}
return

Here is the second script (no desktop changes):

Code: Select all

#SingleInstance, force
#Persistent
#NoTrayIcon
SetWorkingDir %A_ScriptDir%

; Xp Luna Shutdown Dialog
; by Aaron Bewza, but thanks to the AHK community for letting me use pieces and tidbits of various stuff from throughout the years
; a recreation of the Windows XP Shutdown screen

SetTimer CheckHoverDesktop, 50 ; checks if mouse over desktop

;WinMinimizeAll

ButtonCount = 3 ; sets starting parameters for these variables
MouseOnButton = 0
ButtonMouseOn = 
MidClick = 0

Gui, Add, Picture, w320 h-1 x1 y0 , backgrounds\bkg.png		; background image
AddGraphicBtn("x56", "y80", "h36", "w36", "Btn1", "buttons\Standby.jpg", "buttons\StandbyHover.jpg", "buttons\StandByDown.jpg") ; adds button images via function
AddGraphicBtn("x144", "y80", "h36", "w36", "Btn2", "buttons\TurnOff.jpg", "buttons\TurnOffHover.jpg", "buttons\TurnOffDown.jpg")
AddGraphicBtn("x232", "y80", "h36", "w36", "Btn3", "buttons\Restart.jpg", "buttons\RestartHover.jpg", "buttons\RestartDown.jpg")

Gui, Add, Button, x250 y173 w56 h18 gCancel, Cancel			; Cancel button
Gui, Font, s8
Gui, Add, Text, Center x10 y168 w230 r2 cWhite vTextArea 	; creates text area for button info
Gui, Color, 003298											; matches the dark blue top/bottom colors of gui background image

Gui, Margin, 1, 0
OnMessage(0x200, "MouseMove")
OnMessage(0x201, "MouseLDown")
OnMessage(0x202, "MouseLUp")
 SysGet, Height, 17						; gets height of monitor in pixels
 QuarterHeight := Height / 4
 Yposition := Round(QuarterHeight)		; rounds to single digit, no decimals
Gui -Caption +ToolWindow +AlwaysOnTop
Gui, Show, y%Yposition%					; uses calculated screen height to determine distance from top

GuiControl, 1:Hide, Btn1Hvr				; hide the non-regular button images
GuiControl, 1:Hide, Btn2Hvr
GuiControl, 1:Hide, Btn3Hvr
GuiControl, 1:Hide, Btn1Dwn
GuiControl, 1:Hide, Btn2Dwn
GuiControl, 1:Hide, Btn3Dwn
WinGet, id, ID, A						; gets window ID
Return

CheckHoverDesktop: ; check if the mouse is over program window or desktop.
MouseGetPos,,, hwnd
WinExist("ahk_id " hwnd)
WinGet, detection, ProcessName	; assigns "detection" variable with window's ID under the mouse.
if detection = explorer.exe		; if mouse is over the desktop and not the program window.
{
	Hotkey, LButton, ding, On	; disables mouse/keyboard functions and makes it "ding" instead.
	Hotkey, MButton, ding, On
	Hotkey, RButton, ding, On
	Hotkey, XButton1, ding, On
	Hotkey, XButton2, ding, On
	Hotkey, WheelUp, ding, On
	Hotkey, WheelDown, ding, On
	Hotkey, LWin, ding, On
	Hotkey, RWin, ding, On
	Hotkey, Tab, ding, On
	Hotkey, Space, ding, On
	Hotkey, Enter, ding, On
	Hotkey, Control, ding, On
	Hotkey, Alt, ding, On
	Hotkey, Space, ding, On
	Hotkey, !Tab, ding, On
	Hotkey, ^+Tab, ding, On
}
if detection != explorer.exe	; if mouse is over program window and not the desktop
{
	MouseMove, %x%, %y% 
	Hotkey, LButton, ding, Off	; removes mouse/keyboard restrictions.
	Hotkey, MButton, ding, Off
	Hotkey, RButton, ding, Off
	Hotkey, XButton1, ding, Off
	Hotkey, XButton2, ding, Off
	Hotkey, WheelUp, ding, Off
	Hotkey, WheelDown, ding, Off
	Hotkey, LWin, ding, Off
	Hotkey, RWin, ding, Off
	Hotkey, Tab, ding, Off
	Hotkey, Space, ding, Off
	Hotkey, Enter, ding, Off
	Hotkey, Control, ding, Off
	Hotkey, Alt, ding, Off
	Hotkey, Space, ding, Off
	Hotkey, !Tab, ding, Off
	Hotkey, ^+Tab, ding, Off
}
return

Btn1_up: ; mouse-up event on button 1
SoundPlay, sounds\click.wav
RestoreCursor() ; restores cursor to normal
  DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) ; command for sleep/stand by.
ExitApp
Return

Btn2_up: ; mouse-up event on button 2
SoundPlay, sounds\click.wav
RestoreCursor()
  Shutdown, 9 ; shuts down computer
ExitApp
Return

Btn3_up: ; mouse-up event on button 3
SoundPlay, sounds\click.wav
RestoreCursor()
  Shutdown, 2 ; restarts computer
ExitApp
Return

ding:
SoundPlay, sounds\ding.wav
return

Nothing:
Return

Esc::
Cancel:
SoundPlay, sounds\click.wav
RestoreCursor()
;WinMinimizeAllUndo ; restores minimized windows
ExitApp
return

; |-------------------------------------------------------------------------------------------------------|
; |--------------------------------------------- functions -----------------------------------------------|
; |-------------------------------------------------------------------------------------------------------|

AddGraphicBtn(Btn_X, Btn_Y, Btn_H, Btn_W, Btn_Identifier, Btn_Up, Btn_Hvr, Btn_Dwn) ; add image buttons
{
	Global
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Hvr hwnd%Btn_Identifier%Hvr_hwnd, %Btn_Hvr%
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier%Dwn hwnd%Btn_Identifier%Dwn_hwnd, %Btn_Dwn%
	Gui, Add, Picture, +altsubmit %Btn_X% %Btn_Y% %Btn_H% %Btn_W% gNothing v%Btn_Identifier% hwnd%Btn_Identifier%_hwnd, %Btn_Up%
}

MouseMove(wParam, lParam, msg, hwnd) ; mouse-over images
{
	Global
	Loop, %ButtonCount%
	{
		If MouseOnButton = 0
		{
			if (hwnd = Btn1_HWND) ; mouse-over image button 1
			{
				GuiControl, Hide, Btn1
				GuiControl, Hide, Btn1Dwn
				GuiControl, Show, Btn1Hvr ; shows button 1 hover image
				GuiControl, Text, TextArea, Stand By - Keeps your session in memory and`nputs the computer in a low-power state.
				MouseOnButton = 1
				ButtonMouseOn = Btn1
				SetCursor() ; sets cursor to hand pointer
				Break
			}
			if (hwnd = Btn2_HWND) ; mouse-over image button 2
			{
				GuiControl, Hide, Btn2
				GuiControl, Hide, Btn2Dwn				
				GuiControl, Show, Btn2Hvr ; shows button 2 hover image
				GuiControl, Text, TextArea, Turn Off - Shuts down Windows so you`ncan safely turn off the computer.
				MouseOnButton = 1
				ButtonMouseOn = Btn2
				SetCursor()
				Break
			}
			if (hwnd = Btn3_HWND) ; mouse-over image button 3
			{
				GuiControl, Hide, Btn3
				GuiControl, Hide, Btn3Dwn				
				GuiControl, Show, Btn3Hvr ; shows button 3 hover image
				GuiControl, Text, TextArea, Restart - Shuts down Windows and`nthen starts Windows again.
				MouseOnButton = 1
				ButtonMouseOn = Btn3
				SetCursor()
				Break
			}
			RestoreCursor() ; restores cursor to regular
		}
	}
	If (MouseOnButton = 1) and (hwnd = id) and (MidClick = 0) ; mouse is not over buttons, but still in window
	{
		GuiControl, Show, %ButtonMouseOn%
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Text, TextArea ; removes any text present in the control
		MouseOnButton = 0
		ButtonMouseOn = 
		RestoreCursor() ; restores cursor to regular
	}
	If (hwnd != %ButtonMouseOn%_HWND) and (hwnd != %ButtonMouseOn%Hvr_HWND) and (hwnd != %ButtonMouseOn%Dwn_HWND) and (hwnd != id) ; mouse is not over buttons OR window
	{
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Show, %ButtonMouseOn%
		GuiControl, Text, TextArea ; removes any text present in the control
		MouseOnButton = 0
		ButtonMouseOn = 
		RestoreCursor() ; restores cursor to regular once mouse is not over image
	}
	Return
}

MouseLDown(wParam, lParam, msg, hwnd) ; mouse-down on images
{
	Global
	MidClick = 1 ; prevents mousemove from presuming mouse is no longer over image
	If (hwnd = %ButtonMouseOn%Hvr_HWND)
	{
		GuiControl, Hide, %ButtonMouseOn%Hvr
		GuiControl, Hide, %ButtonMouseOn%
		GuiControl, Show, %ButtonMouseOn%Dwn
	}
	MidClick = 0
	GetKeyState, MouseLBtnState, LButton, P
	If MouseLBtnState = U
		MouseLUp("", "", "", %hwnd%)
	Return
}

MouseLUp(wParam, lParam, msg, hwnd) ; mouse-up after clicking images
{
	Global
	MidClick = 1
	If (hwnd = %ButtonMouseOn%Dwn_HWND)
	{
		GuiControl, Hide, %ButtonMouseOn%Dwn
		GuiControl, Hide, %ButtonMouseOn%
		GuiControl, Show, %ButtonMouseOn%Hvr
		GoSub % ButtonMouseOn . "_Up"
	}
	MidClick = 0
	Return
}

SetCursor() ; change cursor to pointer
{
    CursorHandle := DllCall("LoadImage", "Uint", 0, "Uint", 32649, "Uint", 2, "Uint", 0, "Uint", 0, "Uint", 0x8000)
    DllCall("SetSystemCursor", Uint, CursorHandle, Int, 32512)
}

RestoreCursor() ; restores cursor to normal
{
    DllCall("SystemParametersInfo", UInt, 0x57, UInt, 0, UInt, 0, UInt, 0)
}
return

Last edited by WeedTrek on 18 Sep 2020, 00:02, edited 10 times in total.
gwarble
Posts: 459
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: 26
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: 459
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: 26
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 203 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: 820
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: 459
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: 26
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: 820
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: 26
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

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Chiefkes, Spikea and 22 guests