AutoHotkey Community

It is currently May 24th, 2012, 2:19 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: September 6th, 2005, 7:39 pm 
Offline

Joined: March 2nd, 2004, 10:10 pm
Posts: 443
Location: SLC, Utah
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.

Image

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Great script
PostPosted: September 6th, 2005, 7:55 pm 
Offline

Joined: August 21st, 2005, 12:25 pm
Posts: 12
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 :D)

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

Thank you for the hint :),
Mon

Nice modification Andre :D


Last edited by Mon on September 6th, 2005, 8:37 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2005, 8:01 pm 
Offline

Joined: July 22nd, 2005, 7:36 am
Posts: 52
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 11th, 2005, 9:49 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2005, 8:20 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2005, 3:21 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
Nice :) . Thanks for sharing beardboy :D

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 :D .
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2005, 7:26 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2005, 7:31 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2005, 7:35 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2005, 2:46 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
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 :) ,

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... :lol: . Maybe beardboy will made the change in the next version (if there is going to be a next version)...


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: jsquard, maraskan_user, RaptorX and 21 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