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 

Notification Window (Like MSN Messenger Popups)

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



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Tue Sep 06, 2005 7:39 pm    Post subject: Notification Window (Like MSN Messenger Popups) Reply with quote

I'm not sure if someone has already posted something like this, but if not here you go. Include this file in any script and use one line to popup notifications like MSN Messenger Popups. The popup plays a sound if wanted, rolls up, waits X number of milliseconds, then rolls back down and disapears.



Example of adding it to your AHK File:
Code:
#NoTrayIcon
beardboyTray("Meeting","`n`nDon't forget you have a meeting!!!`nTime: 11:00am`nPlace: Conference Room",1,2000) ; Play sound and custom 2 second delay
WinWaitClose, Meeting
ExitApp

#Include beardboyTray.ahk


beardboyTray.ahk
Code:
; Program: Beardboy Tray
; Version: .00
; Last Modified: 2005.09.06
; Last Changes: First Version

/*
Example of how to popup a message
beardboyTray(title,text,sound,timeout)
beardboyTray("beardboy's TrayTip","This is a Test") ; No sound and Default 4 second timeout
beardboyTray("beardboy's TrayTip","This is a Test",0,10000) ; No sound and Custom 10 second timeout.
beardboyTray("beardboy's TrayTip","This is a Test",1,0) ; Sound and User must close TrayTip
*/

beardboyTray(title,text, sound = 0, timeout = 4000)
{
  global
  bt_title = %title%
  x := % A_ScreenWidth - 185
  y := % A_ScreenHeight - 30
  gui, 99:+ToolWindow +border
  gui, 99:color, FFFFFF
  gui, 99:Margin, 0, 0
  gui, 99:Add, Text, center w175 h90 cBlue, %text%
  Gui, 99:Show, x%x% y%y%, %title%

  if sound <> 0
    SoundPlay, %SystemRoot%\Media\notify.wav
  SetWinDelay, 5
  WinGetPos,, guiy,,, %title%
  Loop, 55
  {
    guiy -= 2
    WinMove, %title%,,, %guiy%
  }
  if timeout <> 0
    SetTimer, CloseTray, %timeout%
}

99GuiClose:
Gui, 99:Destroy
return

CloseTray:
SetTimer, CloseTray, Off
SetWinDelay, 5
WinGetPos,, guiy,,, %bt_title%
Loop, 55
{
  guiy += 2
  WinMove, %bt_title%,,, %guiy%
}
Gui, 99:Destroy
return


thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Mon



Joined: 21 Aug 2005
Posts: 12

PostPosted: Tue Sep 06, 2005 7:55 pm    Post subject: Great script Reply with quote

Wow...this is nice.
Smooth in window move and looks great!
I also love the use of #Include *.ahk, smart(yes, another lesson from great script Very Happy)

...I just configured my script to use #Include.
It made everthing a lot easier to control!! Very Happy

Thank you for the hint Smile,
Mon

Nice modification Andre Very Happy


Last edited by Mon on Tue Sep 06, 2005 8:37 pm; edited 2 times in total
Back to top
View user's profile Send private message
Andre



Joined: 22 Jul 2005
Posts: 52

PostPosted: Tue Sep 06, 2005 8:01 pm    Post subject: Reply with quote

hi,

some mods.
Like alwaysontop & Transparent

Code:
; Program: Beardboy Tray
; Version: .00
; Last Modified: 2005.09.06
; Last Changes: First Version

/*
Example of how to popup a message
beardboyTray(title,text,sound,timeout)
beardboyTray("beardboy's TrayTip","This is a Test") ; No sound and Default 4 second timeout
beardboyTray("beardboy's TrayTip","This is a Test",0,10000) ; No sound and Custom 10 second timeout.
beardboyTray("beardboy's TrayTip","This is a Test",1,0) ; Sound and User must close TrayTip
*/

beardboyTray(title,text, sound = 0, timeout = 4000)
{
  global
  bt_title = %title%
  x := % A_ScreenWidth - 185
  y := % A_ScreenHeight - 30
  gui, 99:+ToolWindow +border +AlwaysOnTop
  gui, 99:
  gui, 99:color, FFFFFF
  gui, 99:Margin, 0, 0
  gui, 99:Add, Text, center w175 h90 cBlue, %text%
  Gui, 99:Show, x%x% y%y%, %title%
 
  WinSet, Transparent, 150, %title%
 
  if sound <> 0
    SoundPlay, %SystemRoot%\Media\notify.wav
  SetWinDelay, 5
  WinGetPos,, guiy,,, %title%
  Loop, 55
  {
    guiy -= 2
    WinMove, %title%,,, %guiy%
  }
  if timeout <> 0
    SetTimer, CloseTray, %timeout%
}

99GuiClose:
Gui, 99:Destroy
return

CloseTray:
SetTimer, CloseTray, Off
SetWinDelay, 5
WinGetPos,, guiy,,, %bt_title%
Loop, 55
{
  guiy += 2
  WinMove, %bt_title%,,, %guiy%
}
Gui, 99:Destroy
return


regards,
Andre
Back to top
View user's profile Send private message
evl



Joined: 24 Aug 2005
Posts: 1238

PostPosted: Sun Sep 11, 2005 9:49 pm    Post subject: Reply with quote

Don't know if it's the case when included in another script, but when run on its own, it needs a "Return" added at the end of the section which is above "99GuiClose:".

Thanks for sharing though - useful script.
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Mon Sep 12, 2005 8:20 am    Post subject: Reply with quote

evl wrote:
Don't know if it's the case when included in another script, but when run on its own, it needs a "Return" added at the end of the section which is above "99GuiClose:".
It is a function, so AFAIK it should not need a return. But I didn't test. But in general you should include this file into your script and call the function it is not ment to run by itself.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Tue Sep 13, 2005 3:21 am    Post subject: Reply with quote

Nice Smile . Thanks for sharing beardboy Very Happy

I wanted to use it as a stand-alone app that I could launch using Run/RunWait so I made a modified version for that purpose with a few other modifications. Here's the modified version in case you find any of it useful... Thanks again Very Happy .
Code:
; Program: Beardboy Tray
; Version: corr0.02
; Last Modified: 2005.09.12
; Last Changes: Modified Version - Corrupt

; - Modified: from include file to stand-alone script (use Runwait to launch)
; - Modified: AlwaysOnTop method to prevent showing message window over taskbar
; - Modified: WinMove method to API call "MoveWindow" for speed/smoothing
; - Added: click anywhere on the message to close the message window
; - Modified: Window always moves back down before closing

; RunWait, beardboytray.ahk "title" "text" "sound" "timeout"

; All params are optional (default values will be used if not specified)
; Set timeout to 0 to manually dismiss message (click on message window to close)

#SingleInstance, Ignore
#NoTrayIcon
  title = %1%
  if !title
    title = Beardboy Tray
  text = %2%
  If !text
    text = `nBeardboy Tray`n`nModified by: Corrupt`nVersion: corr.02
  sound = %3%
  If !sound 
    sound := 0
  timeout = %4%
  If timeout=
    timeout := 4000

  x := % A_ScreenWidth - 191
  y := % A_ScreenHeight - 30
  gui, Add, Text, center w175 h90 cRed, %text%
  gui, +ToolWindow +border
  gui, color, FFFFFF
  gui, Margin, 0, 0
  Gui, Show, x%x% y%y% , %title%
  WinSet, Transparent, 200, %title%
  WinWait, %title%
  WinHWND := WinExist(title)
  OnMessage(0x201, "WM_LBUTTONDOWN")
  if sound <> 0
    SoundPlay, %SystemRoot%\Media\notify.wav
  SetWinDelay, 5
  WinGetPos,, guiy,,, %title%
  Loop, 60
  {
    guiy -= 2
    DllCall("MoveWindow", "UINT", WinHWND, "INT", x, "INT", guiy, "INT", 190, "INT", "120", "INT", "1")
    WinActivate, %title%
  }
  WinSet, AlwaysOnTop, On
  if timeout <> 0
    SetTimer, CloseTray, %timeout%
Return

WM_LBUTTONDOWN(wParam, lParam)
{
if !closing
  SetTimer, CloseTray, 200
}

GuiClose:
CloseTray:
closing := True
WinSet, AlwaysOnTop, Off, %title%
SetWinDelay, 5
WinGetPos,, guiy,,, %title%
Loop, 60
{
  guiy += 2
  DllCall("MoveWindow", "UINT", WinHWND, "INT", x, "INT", guiy, "INT", 190, "INT", "120", "INT", "1")
  WinActivate, %title%
}
SetTimer, CloseTray, Off
ExitApp
Return


Sample calling script:
Code:
#NoTrayIcon
title = Meeting
Message = `nDon't forget you have a meeting!!!`nTime: 11:00am`nPlace: Conference Room
sound =
timeout = 2000

RunWait, Autohotkey beardboytray.ahk "%title%" "%Message%" 1 0

RunWait, Autohotkey beardboytray.ahk "This is a Modified Version" "`nBeardboy Tray`n`nModified by Corrupt" 1
ExitApp
Back to top
View user's profile Send private message Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Tue Sep 13, 2005 7:26 am    Post subject: Reply with quote

Hi Corrupt,
nice idea,

What are the "%" doing in these lines
Code:
  x := % A_ScreenWidth - 191
  y := % A_ScreenHeight - 30
It should work without them, don't it?
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Tue Sep 13, 2005 7:31 am    Post subject: Reply with quote

To get the command line params could look like this
Code:
 var1 = Beardboy Tray
 var2 = `nBeardboy Tray`n`nModified by: Corrupt`nVersion: corr.02
 var3 := 0
 var4 := 4000
Loop, %0%
     var%A_index% = %A_Index%
But this is just personal likings. The drawback is that you loose the speaking names.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Tue Sep 13, 2005 7:35 am    Post subject: Reply with quote

I would suggest to get the UniqueID for the GUI and use it for the gui manipulation, so that it is more robust (compared to using %title%)
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
corrupt



Joined: 29 Dec 2004
Posts: 2393

PostPosted: Wed Sep 14, 2005 2:46 am    Post subject: Reply with quote

toralf wrote:
Hi Corrupt,
nice idea,

What are the "%" doing in these lines
Code:
  x := % A_ScreenWidth - 191
  y := % A_ScreenHeight - 30
It should work without them, don't it?


Hi toralf Smile ,

Yes, it should work ok without them. Although I made a few modifications much of the original code remained.

toralf wrote:
I would suggest to get the UniqueID for the GUI and use it for the gui manipulation, so that it is more robust (compared to using %title%)

I had actually made that change and then reverted back (along with a few other changes) to troubleshoot a pesky bug that I had introduced. After troubleshooting I didn't end up putting it back in... Laughing . Maybe beardboy will made the change in the next version (if there is going to be a next version)...
Back to top
View user's profile Send private message Visit poster's website
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