[Function] Smart WinFade[In|Out]

Post your working scripts, libraries and tools
User avatar
joedf
Posts: 6482
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

[Function] Smart WinFade[In|Out]

Post by joedf » 03 Nov 2013, 15:45

Arguments
  • w : wintitle
    t : final transparency
    i : increment
    d : delay (between each increment)
Behaviour
  • if : t > current, increases current transparency [i+]
    if : t < current, decreases current transparency [i-]
Usage
  • Code: Select all

    Gui Color, 0x1A1A1A
    Gui +E0x20 -Caption +LastFound +ToolWindow +AlwaysOnTop +hwndHgui
    WinSet, Transparent, 0
    Gui Show, x0 y0 w%A_screenwidth% h%A_screenHeight%
    winfade("ahk_id " Hgui,100,5) ;fade in
    sleep 1000
    winfade("ahk_id " Hgui,10,5) ;fade out
    exitapp
Function
  • Code: Select all

    winfade(w:="",t:=128,i:=1,d:=10) { ; by joedf  -  http://ahkscript.org/boards/viewtopic.php?f=6&t=512
    	w:=(w="")?("ahk_id " WinActive("A")):w
    	t:=(t>255)?255:(t<0)?0:t
    	WinGet,s,Transparent,%w%
    	s:=(s="")?255:s ;prevent trans unset bug
    	WinSet,Transparent,%s%,%w% 
    	i:=(s<t)?abs(i):-1*abs(i)
    	while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
    		WinGet,s,Transparent,%w%
    		s+=i
    		WinSet,Transparent,%s%,%w%
    		sleep %d%
    	}
    }
User avatar
huyaowen
Posts: 100
Joined: 28 Jul 2014, 01:15

Re: [Function] Smart WinFade[In|Out]

Post by huyaowen » 23 Sep 2014, 02:32

nice,thanks.
User avatar
joedf
Posts: 6482
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] Smart WinFade[In|Out]

Post by joedf » 23 Sep 2014, 08:52

You're welcome. :)
Skrell
Posts: 163
Joined: 23 Jan 2014, 12:05

Re: [Function] Smart WinFade[In|Out]

Post by Skrell » 24 Sep 2014, 08:30

What are you currently using this function for Joedf? Are you just using hotkeys to fade the active window at will?
User avatar
joedf
Posts: 6482
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] Smart WinFade[In|Out]

Post by joedf » 25 Sep 2014, 11:36

Well, it was originally created for Qonsole ;)
http://qonsole-ahk.sourceforge.net/
User avatar
h0ll0w
Posts: 4
Joined: 29 Jan 2014, 11:55
Location: Colorado
Contact:

Re: [Function] Smart WinFade[In|Out]

Post by h0ll0w » 30 Sep 2014, 08:48

thanks joedf this will help me out a lot!
AHK 1.1.26.01 OS Win 7 and 10
User avatar
joedf
Posts: 6482
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada, Quebec
Contact:

Re: [Function] Smart WinFade[In|Out]

Post by joedf » 30 Sep 2014, 15:47

no problemo ;)
Post Reply

Return to “Scripts and Functions”