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 

Alwaysontop does not work with transparency

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
mb777



Joined: 08 Jan 2009
Posts: 42

PostPosted: Thu Jan 08, 2009 11:31 pm    Post subject: Alwaysontop does not work with transparency Reply with quote

I have written a function to display an information box.

Although I have specified +Alwaysontop, it always appears behind my main window!!

It is to do with the fact that I am using transparency, because when I comment out the transparency lines, it works fine.

However I would like to keep the transparency feature. HAve I programmed something wrong, or is it a limitation?

Here is the code:
Code:


infobox1(movebox =1,boxtext ="",pic ="",pich ="",boxnumber =10,interval =5,awayinterval =5,infocolor ="e72e49"
,infosound ="",infofont ="",infofontsize =14)
{
   detecthiddenwindows,on
   ;ControlGetPos ,flarex,flarey,,,Button23,Worms Automator
   title:=title="" ? "...Information..." : title
   topmargin:=10
   pictextgap:=10
   coordmode,mouse,screen                 ;set coords to be relative to screen - not active window
   mouseGetPos ,flarex,flarey
   ;msgbox %flarex%,%flarey%
   flarex20:=flarex+20
   SysGet, maxpix, Monitor
   ;msgbox gui.%boxnumber%:color.%infosound%
   gui, %boxnumber%:+alwaysontop +owner1 +noactivate ;-sysmenu
   gui, %boxnumber%:color,%infocolor%
   gui, %boxnumber%:font,s%infofontsize%,%infofont%
   gui, %boxnumber%:add, text, x10 y10 center hwndinfobox1id,%boxtext%
   ystart:=movebox=1 ? maxpixbottom : flarey
   gui, %boxnumber%:show,hide x%flarex20% y%ystart%,%title%
   
   if (pic<>"")
   {
      pichandle:=addlogo(boxnumber,pic,topmargin,pich,title)
      if (pich="")
         controlgetpos,,,,pich,,ahk_id%pichandle% ;get height of pic if not specified
   }
   controlmove,,,topmargin+pich+pictextgap+20,,,ahk_id%infobox1id%
   winset,transparent,0,%title%
   gui, %boxnumber%:show,autosize
   
   playit(infosound)
   trans:=0
   count:=maxpixbottom
   ;msgbox,%moveto%
   loop
   {
      if (count<=flarey)
         break
      trans+=(250/((maxpixbottom-flarey)//interval))
      
      winset,transparent,%trans%,%title%
      winset,alwaysontop,on,%title%
      if movebox
      {
         winmove,%title%,,flarex20,%count%
      }
      count-=interval
       sleep 50
   }
   sleep 2000
   count:=flarey
   trans:=250
   loop
   {
      if (count>=maxpixbottom)
         break
      trans-=(250/((maxpixbottom-flarey)//awayinterval))
      winset,transparent,%trans%,%title%
      winset,alwaysontop,on,%title%
      if movebox
         winmove,%title%,,flarex20,%count%
      sleep 50
      count+=awayinterval
   }
gui, %boxnumber%:destroy
detecthiddenwindows,off
return
}


addlogo(winnumber,pic="",ypos =10,pich="",wintitle="")  ;centres a pic in a window horizontally
{                           ;no matter what size window
 ;msgbox %wintitle%
   if (wintitle <>"")
   {
      wingetpos,,,winwidth,,%wintitle%
      }
   else
      wingetpos,,,winwidth
   gui, %winnumber%:add,picture,hwndpichandle y%ypos% h%pich% w-1,%pic%
   controlgetpos,,,picwidth,picheight,, ahk_id%pichandle%
   xco:=(winwidth/2)-(picwidth/2)
   ;msgbox %winwidth%.%xco%.%picwidth%.%picheight%.%pichandle%.%wintitle%
   controlmove,,xco,,,,ahk_id%pichandle%
   return pichandle
}
Back to top
View user's profile Send private message
Chavez



Joined: 20 Aug 2008
Posts: 256

PostPosted: Fri Jan 09, 2009 6:36 am    Post subject: Reply with quote

Take a look in my topic that simulates a broken LCD screen which uses transparency and always on top.

Next time post here though.
_________________
-Chavez.
Back to top
View user's profile Send private message MSN Messenger
wrong section alarm
Guest





PostPosted: Fri Jan 09, 2009 6:42 am    Post subject: Reply with quote

mb777 wrote:
It is to do with the fact that I am using transparency, because when I comment out the transparency lines, it works fine.

However I would like to keep the transparency feature. HAve I programmed something wrong, or is it a limitation?


Ask(ing) for Help
Back to top
mb777



Joined: 08 Jan 2009
Posts: 42

PostPosted: Fri Jan 09, 2009 7:28 am    Post subject: Solution Reply with quote

I found out the problem...

Code:
infobox1(movebox =1,boxtext ="",pic ="",pich ="",boxnumber =10,interval =5,awayinterval =5,infocolor ="e72e49"
,infosound ="",infofont ="",infofontsize ="s14")
{
   detecthiddenwindows,on
   ;ControlGetPos ,flarex,flarey,,,Button23,Worms Automator
   title:=title="" ? "...Information..." : title
   topmargin:=10
   pictextgap:=10
   coordmode,mouse,screen                 ;set coords to be relative to screen - not active window
   mouseGetPos ,flarex,flarey
   ;msgbox %flarex%,%flarey%
   flarex20:=flarex+20
   SysGet, maxpix, Monitor
   ;msgbox gui.%boxnumber%:color.%infosound%
   gui, %boxnumber%:+lastfound +alwaysontop +toolwindow     ;+owner1 +noactivate
   gui, %boxnumber%:color,%infocolor%
   gui, %boxnumber%:font,%infofontsize%,%infofont%
   gui, %boxnumber%:add, text, x10 y10 center hwndinfobox1id,%boxtext%
   ystart:=movebox=1 ? maxpixbottom : flarey
   gui, %boxnumber%:show,hide x%flarex20% y%ystart%,%title%
   
   if (pic<>"")
   {
      pichandle:=addlogo(boxnumber,pic,topmargin,pich,title)
      if (pich="")
         controlgetpos,,,,pich,,ahk_id%pichandle% ;get height of pic if not specified
   }
   controlmove,,,topmargin+pich+pictextgap+20,,,ahk_id%infobox1id%
   winset,transparent,0,%title%
   gui, %boxnumber%:show,autosize
   
   playit(infosound)
   trans:=0
   count:=maxpixbottom
   ;msgbox,%moveto%
   loop
   {
      if (count<=flarey)
         break
      trans+=(250/((maxpixbottom-flarey)//interval))
      
      winset,transparent,%trans%,%title%
      if movebox
      {
         winmove,%title%,,flarex20,%count%
      }
      count-=interval
       sleep 50
   }
   sleep 2000
   count:=flarey
   trans:=250
   loop
   {
      if (count>=maxpixbottom)
         break
      trans-=(250/((maxpixbottom-flarey)//awayinterval))
      winset,transparent,%trans%,%title%
      if movebox
         winmove,%title%,,flarex20,%count%
      sleep 50
      count+=awayinterval
   }
gui, %boxnumber%:destroy
detecthiddenwindows,off
return
}


The line in red should read:

winset,transparent,1,%title%

ie: It should be anything but 0 - then it works.
Back to top
View user's profile Send private message
Sivvy



Joined: 21 Jul 2008
Posts: 726
Location: Calgary, AB, Canada

PostPosted: Fri Jan 09, 2009 3:15 pm    Post subject: Reply with quote

That kinda looks similar to "WinHide"...

Code:
WinHide, %Title%
Sleep, 1000
WinShow, %Title%

Might not be what you want, but as far as I know... Transparency 0 is equivalent to WinHide.
Back to top
View user's profile Send private message
mb777



Joined: 08 Jan 2009
Posts: 42

PostPosted: Sun Jan 11, 2009 1:46 pm    Post subject: Transparency / Fade In / Out Reply with quote

I was using transparency to fade in and out a window.

There is a much easier way I've discovered!

http://www.autohotkey.com/forum/viewtopic.php?p=65596#65596
[/url]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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