 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
mb777
Joined: 08 Jan 2009 Posts: 42
|
Posted: Thu Jan 08, 2009 11:31 pm Post subject: Alwaysontop does not work with transparency |
|
|
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 |
|
 |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
|
| Back to top |
|
 |
wrong section alarm Guest
|
Posted: Fri Jan 09, 2009 6:42 am Post subject: |
|
|
| 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
|
Posted: Fri Jan 09, 2009 7:28 am Post subject: Solution |
|
|
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 |
|
 |
Sivvy
Joined: 21 Jul 2008 Posts: 726 Location: Calgary, AB, Canada
|
Posted: Fri Jan 09, 2009 3:15 pm Post subject: |
|
|
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 |
|
 |
mb777
Joined: 08 Jan 2009 Posts: 42
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|