Re: PleasantNotify() - Beautiful popup msg, tooltip
Posted: 09 Jan 2017, 22:48
This is great! But how do I exit the app after it's faden out? I tried putting "ExitApp" all around, but it won't work properly. Any ideas?
Let's help each other out
https://www.autohotkey.com/boards/
Code: Select all
^=::
SnapGrid++
MouseGetPos CurX, CurY
if(SnapGrid>=6)
{
SnapGrid:=1
}
if (SnapGrid=1) ;beat
{
PleasantNotify(" OHH, SNAP!", " beat" , 200, 120, "b hc", "0.7")
click, 960, 100
click, 960, 400
MouseMove %CurX%, %CurY%, 0
}
else if(SnapGrid=2) ;1/2 beat
{
PleasantNotify(" OHH, SNAP!", " 1/2 beat" , 200, 120, "b hc", "0.7")
click, 960, 100
Click, 960, 377
MouseMove %CurX%, %CurY%, 0
}
else if(SnapGrid=3) ;1/4 beat
{
PleasantNotify(" OHH, SNAP!", " 1/4 beat" , 200, 120, "b hc", "0.7")
click, 960, 100
Click, 960, 333
MouseMove %CurX%, %CurY%, 0
}
else if (SnapGrid=4) ;1/2 step
{
PleasantNotify(" OHH, SNAP!", " 1/2 step" , 200, 120, "b hc", "0.7")
click, 960, 100
Click, 960, 268
MouseMove %CurX%, %CurY%, 0
}
else if(SnapGrid=5) ;1/4 step
{
PleasantNotify(" OHH, SNAP!", " 1/4 step" , 200, 120, "b hc", "0.7")
Click, 960, 100
Click, 960, 225
MouseMove %CurX%, %CurY%, 0
}
return
PleasantNotify(title, message, pnW=700, pnH=300, position="b r", time=10) {
global pn_title, pn_msg, PN_hwnd, w, h
Notify_Destroy()
Gui, Notify: +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
PN_hwnd := WinExist()
WinSet, ExStyle, +0x200 ; change to +0x20 if don't like white lines
WinSet, Transparent, 0
Gui, Notify: Color, 0x596066 ;window color
Gui, Notify: Font, c0xBlack s17 wLight, Segoe UI Light ;title color/size/font type
Gui, Notify: Add, Text, % " x" 20 " y" 12 " w" pnW-20 " vpn_title", % title
Gui, Notify: Font, c0xefcb7a s25 wBold, Segoe UI ;message color/size/font type
Gui, Notify: Add, Text, % " x" 20 " y" 56 " w" pnW-20 " h" pnH-56 " vpn_msg", % message
RealW := pnW + 50 ;notification position X
RealH := pnH + 250 ;notification position Y
Gui, Notify: Show, W%RealW% H%RealH% NoActivate
WinMove(PN_hwnd, position)
if A_ScreenDPI = 96
WinSet, Region,0-0 w%pnW% h%pnH% R40-40,%A_ScriptName%
/* For Screen text size 125%
if A_ScreenDPI = 120
WinSet, Region, 0-0 w800 h230 R40-40, %A_ScriptName%
*/
winfade("ahk_id " PN_hwnd, 210, 10000000) ; window transperency level 0-211","FADE-IN time 50+"
if (time <> "P")
{
Closetick := time*1000 ;time window is on 0-1000 or maybe more
SetTimer, ByeNotify, % Closetick
}
}
Notify_Destroy() {
global PN_hwnd
ByeNotify:
SetTimer, ByeNotify, Off
winfade("ahk_id " PN_hwnd,0,40) ; fade-out effect
Gui, Notify: Destroy
return
}
pn_mod_title(title) {
global pn_title
GuiControl, Notify: Text,pn_title, % title
}
pn_mod_msg(message) {
global pn_msg
GuiControl, Notify: Text,pn_msg, % message
}
WinMove(hwnd,position) {
SysGet, Mon, MonitorWorkArea
WinGetPos,ix,iy,w,h, ahk_id %hwnd%
x := InStr(position,"l") ? MonLeft : InStr(position,"hc") ? (MonRight-w)/2 : InStr(position,"r") ? MonRight - w : ix
y := InStr(position,"t") ? MonTop : InStr(position,"vc") ? (MonBottom-h)/2 : InStr(position,"b") ? MonBottom - h : iy
WinMove, ahk_id %hwnd%,,x,y
}
winfade(w:="",t:=128,i:=1,d:=10) {
w:=(w="")?("ahk_id " WinActive("A")):w
t:=(t>255)?255:(t<0)?0:t ;(t>255)?255:(t<0)?0:t
WinGet,s,Transparent,%w%
s:=(s="")?255:s ;prevent trans unset bug 255
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%
}
}