WinFadeClose() - WinFadeClose any window! :)

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
joedf
Posts: 9000
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

WinFadeClose() - WinFadeClose any window! :)

Post by joedf » 01 Oct 2013, 18:00

"WinFadeCloseany window/control using "WinTitle"!  :D
This has probably been done before... not sure if it's been done under the form of function, but... Here it is anyways  ;)
 
Note: the "time" variable is the time (ms) it takes for the window to fade away.
 
The Function

Code: Select all

WinFadeClose(WinTitle="A",Time=2000,ActivateWinTitle="ahk_class Shell_TrayWnd") {
	WinGet, WinID, ID, %WinTitle%
		if (ActivateWinTitle!=0) or ActivateWinTitle !=
			Winactivate, %ActivateWinTitle%
	WinDelay := A_WinDelay
	SetWinDelay, 5
	WinGet, Trans, Transparent, ahk_id %WinID%
	Trans := Trans ? Trans : 255
	WinSet, ExStyle, +0x00000020, ahk_id %WinID%
	I := (J:=Trans)*10/(Time/=2)
	Loop, % Time/10 {
		Sleep, 10 ; a delay from 1 to 10 is generally equivalent to 10 or 15.6
		WinSet, Transparent, % J-=I, ahk_id %WinID%
	}
	SetWinDelay, %WinDelay%
	WinClose, ahk_id %WinID%
}
Example Usage

Code: Select all

Run, notepad.exe,,,PID
sleep 1000
WinFadeClose("ahk_pid " . PID)
Changes:
29 May, 2013 :
  • Changed "Deactivate" option to "ActivateWinTitle", Disable with "" or 0
23 April, 2013 :
  • Changed 0x00000020 to +0x00000020, prevents the window from flashing if a window were transparent
19 April, 2013 : I'm open to comments, suggestions, name changes, anything! ... except hate.  ;)
Cheers!
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

timeFlies
Posts: 146
Joined: 22 Oct 2013, 20:54
Location: Somewhere in the northern hemisphere.

Re: WinFadeClose() - WinFadeClose any window! :)

Post by timeFlies » 22 Oct 2013, 23:38

If I'm not mistaken, doesn't Windows already fade close windows? I know Windows 7 does in Aero theme, but doesn't in classic theme. I'm not sure about Windows 8.

Or does this function just lengthen the time of the fading?

User avatar
joedf
Posts: 9000
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: WinFadeClose() - WinFadeClose any window! :)

Post by joedf » 23 Oct 2013, 00:04

Smoother fading... Try the example! ;)
With this function, you get the choose the duration of the fading effect.
:D cheers!
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]

Post Reply

Return to “Scripts and Functions (v1)”