AutoHotkey Community

It is currently May 26th, 2012, 1:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: January 9th, 2009, 12:31 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2009, 7:36 am 
Offline

Joined: August 20th, 2008, 4:25 pm
Posts: 256
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2009, 7:42 am 
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


Report this post
Top
  
Reply with quote  
 Post subject: Solution
PostPosted: January 9th, 2009, 8:28 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2009, 4:15 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
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.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 11th, 2009, 2:46 pm 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
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]


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], patgenn123, poserpro, Yahoo [Bot] and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group