AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fade in/out taskbar

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
channelog



Joined: 17 Sep 2007
Posts: 7

PostPosted: Mon Sep 17, 2007 10:40 pm    Post subject: Fade in/out taskbar Reply with quote

Hi there

I'm new to this programming thing, so this may be a very complicated method of doing this.

How to use the extra real estate though? And I find there's a problem with
the start menu for me, If I open it and close it again a stripe appears on the left of the taskbar. This for you?

Code:


;    Fading in and out taskbar, to work on any screen resolution
;   
;    G.
;

WinGetPos,,, maxX, maxY, Program Manager, 
CoordMode, Mouse, Screen 
Setformat, Float, 0.0               

FadeUnit := maxY/256               ;  we devide the max y into 250 units - the fade in/out increments
Startpoint := MaxY/8               
Endpoint := MaxY/32               


fdregionmin := MaxY - Startpoint   ;  our fade starts here
fdregionmax := MaxY - Endpoint     ;  and ends at this point


transincrement := (255/ ((Startpoint - Endpoint)/ fadeunit))  ;  the transparency increment relative to the fade unit

transp := 0
WinSet, Transparent, %transp%, ahk_class Shell_TrayWnd      ;start off tranparent


#Persistent
SetTimer, Transchecker, 20
return


Transchecker:                           
MouseGetPos, MouseX, MouseY,       
If (MouseY <= fdregionmin)           ; If it's above our fade line, we keep it transparent
{
   transp := 0
   GoSub, update
   return
}
else if (MouseY >= fdregionmax)        ; If the mouse is below, we keep it solid
{
   transp := 255
   Gosub, update   
   return
}
else                                   ;  if it's neither, it's in our fade region         

   ChkRel := fdregionmin                               
   testvar := fdregionmin
   MultiplicationUnit := 1                       

   loop, 24                           
     {
     testvar := ChkRel + FadeUnit
     if (MouseY >= ChkRel) and (MouseY <= testvar)       ;  check in which increment the mouse is at   
     {
       transp := transincrement*MultiplicationUnit         
       if transp > 255
       { 
          transp := 255
          return
       }
       GoSub update                                       
       break
     }
     else
     {
       ChkRel := ChkRel + FadeUnit                       
       MultiplicationUnit := MultiplicationUnit + 1       ;  we need this to determine the relative fade increment
     }
}
}
return


update:
  WinSet, Transparent, %transp%, ahk_class Shell_TrayWnd
return
(alt+c)


be interested in your comments, and the easier ways of doing it
Back to top
View user's profile Send private message
AHKPNH



Joined: 17 Feb 2006
Posts: 35

PostPosted: Tue Sep 18, 2007 10:45 am    Post subject: Reply with quote

very good Very Happy
Back to top
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Tue Sep 18, 2007 10:58 am    Post subject: Reply with quote

Three AHK commands/variables migth be of interest for you.
OnMessage
A_ScreenWidth/A_ScreenHight
SysGet


Get things goin Wink
Back to top
crxvfr



Joined: 10 Mar 2006
Posts: 55

PostPosted: Tue Sep 18, 2007 8:46 pm    Post subject: Reply with quote

Very Cool!
The autohide taskbar often misbehaves. This is a perfect and cool solution.
Back to top
View user's profile Send private message
channelog



Joined: 17 Sep 2007
Posts: 7

PostPosted: Tue Sep 18, 2007 9:16 pm    Post subject: Reply with quote

Thanks bobo,

Here's a reworked and simplified version, seperating the rate of fade from the mouse:

Code:
;
;  Tweakable fading taskbar
;
;  G.
;

CoordMode, Mouse, Screen 
Twk = 190           ; tweak
Twks = 25           ; these

trans := 0
Winset, Transparent, %trans%, ahk_class Shell_TrayWnd
Loop,
{
   MouseGetPos, MsX, MsY, 
   ;WinGetPos,,TBarY,,,ahk_class Shell_TrayWnd

   Deficit := A_ScreenHeight - Twk       ;TBarY - Twk

   If (MsY < Deficit) and (trans = 0)         
   {
      sleep, 30       ; this to give the comp less work
      continue
   }
   else if (MsY > Deficit) and (trans = 255)
   {
      sleep, 30
      continue
   }
   else if (MsY > Deficit) and (trans <> 255)
   {
      unit := 5
      GoSub ChngTrans
   }
   else if (MsY < Deficit) and (trans <> 0)
   {
      unit := -5
      GoSub ChngTrans
   }
}
ChngTrans:
trans := trans + unit
sleep, %Twks%
Winset, Transparent, %Trans%, ahk_class Shell_TrayWnd
return

Back to top
View user's profile Send private message
channelog



Joined: 17 Sep 2007
Posts: 7

PostPosted: Wed Sep 19, 2007 9:38 am    Post subject: AAAAAAAAAARGH Reply with quote

Is there ANY way around the redrawing problems with the start menu???

I think this whole thing is against how windows functions. It feels wrong.
Back to top
View user's profile Send private message
Conquer



Joined: 27 Jun 2006
Posts: 383
Location: Canada

PostPosted: Sun Jun 29, 2008 10:06 pm    Post subject: Reply with quote

Quote:
How to use the extra real estate though?


I know this is kind of a grave dig, but..

channelog: Great script, thanks for sharing.

this is my version of the script: (Allows you to use the extra 'real estate' Wink)

Code:
#SingleInstance,Force
#NoTrayIcon
#NoEnv
OnExit,ExitSub
;
;  Tweakable fading taskbar
;
CoordMode, Mouse, Screen
Twk = 03     ; Area of the taskbar (If mouse goes inside this height the taskbar will fade in)
Twk2 = 35      ; Area of taskbar (until fading out) after it's already visible (should be larger than above)
Twks = 25           ; Speed of animating (higher number = smoother fading but more cpu resources used, & vice versa)
WinSet, AlwaysOnTop, On, ahk_class Shell_TrayWnd
FadeInSpeed = 50     ;Speed to use when showing the taskbar (Mouse in range of taskbar)
FadeOutSpeed = -20     ;(Must be negative) speed for hiding the taskbar (Mouse away from range)

trans := 0
Winset, Transparent, %trans%, ahk_class Shell_TrayWnd
Loop,
{
   MouseGetPos, MsX, MsY
   Deficit := A_ScreenHeight - Twk       ;TBarY - Twk
   Deficit2 := A_ScreenHeight - Twk2

   If (MsY < Deficit2) and (trans = 0)         
   {
      sleep, 30
      continue
   }
   else if (MsY > Deficit) and (trans = 255)
   {
      sleep, 30
      continue
   }
   else if (MsY > Deficit) and (trans <> 255)
   {
      unit := FadeInSpeed
      GoSub ChngTrans
   }
   else if (MsY < Deficit2) and (trans <> 0)
   {
      unit := FadeOutSpeed
      GoSub ChngTrans
   }
}
ChngTrans:
if trans < 5
  WinSet, AlwaysOnTop, Off, ahk_class Shell_TrayWnd
If trans > 4
  WinSet, AlwaysOnTop, On, ahk_class Shell_TrayWnd
trans := trans + unit
if trans > 255
  trans = 255
if trans < 0
  trans = 0
sleep, %Twks%
Winset, Transparent, %Trans%, ahk_class Shell_TrayWnd
return

ExitSub:
Trans = 255
Winset, Transparent, %Trans%, ahk_class Shell_TrayWnd
ExitApp
return


In order to use it you must first change your taskbar's settings (Right click>Properties) and uncheck "Keep the taskbar on top of other windows.

This allows you to have the whole screen as a work area when the taskbar is hidden, just like Windows's AutoHide, but with a nice transparent fading in/out effect, and it seems a lot more reliable than the built in AutoHide feature.

Also, you can now tweak both the "Fade In" area's range, and the "Fade Out" area's range.

Cool


Quote:
Is there ANY way around the redrawing problems with the start menu???


I know what line you're talking about now, and I don't find it much of a problem. I don't see why you'd be opening and closing the start menu like that, and even if you did; the line gets erased when the taskbar fades out then back in.

Any who, I found if you lock your taskbar, the line will not appear. Very Happy



Cool




Edit: It seems since this post I've noticed sometimes the script fails to pickup the mouse getting close to the taskbar. Not sure how it happens or what causes it. Seems to behave just like good old Windows's AutoHide (Sad)
- Changed around a couple of lines and it seems to behave (slightly) better now. Not sure why the lines I moved helped it though.
- Turns out that last update was only helping temporarily. I don't think theres any way to get it to seamlessly show (I experience problems with other AlwaysOnTop windows with the last update) and I also experience problems with maximized windows rarely. I rolled back the script and changed a couple lines again. I don't think I can improve it's random reliability.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group