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%
}
Code: Select all
Run, notepad.exe,,,PID
sleep 1000
WinFadeClose("ahk_pid " . PID)
29 May, 2013 :
- Changed "Deactivate" option to "ActivateWinTitle", Disable with "" or 0
- Changed 0x00000020 to +0x00000020, prevents the window from flashing if a window were transparent
- Applied changes by MasterFocus
- Added "Deactivate" option
Cheers!