Sign in to follow this  
Followers 0

Toast

20 posts in this topic

Posted

I was following the GUI threads for starting/minimizing/maximizing to tray, which got me thinking of what the MS developers call "toast" -- that slide popup (like a toaster) on event that Messenger and some other apps that live in the tray use.

I (for one) would love to be able to add "toast" capability added to some of my system utility/ watchdog programs.

Thanks for all the great work goes to the International Autoit Development team for all the effort and skill that they are putting into this - I dread having to go into Visual Studio now. :ph34r:

Share this post


Link to post
Share on other sites



Posted

Sorry, I don't know this functionality.

Could you explan a little bit more what it means?

Thanks Holger :ph34r:

Share this post


Link to post
Share on other sites

Posted

Could you explan a little bit more what it means?

<{POST_SNAPBACK}>

Holger, Thanks for the response. This link might help. Code Description

"Toast" is the word given to the sliding visual cue when an app (typically in the system tray) brings up a window from the tray containing some content (text, links,buttons) and/or plays a sound. The name comes from some wiseacre deciding that the visual cue operated a lot like a toaster, when the bread's done, out it pops. I think I've seen a winamp knockoff use toast to slide up the next song info when transitioning in a playlist, etc.

Share this post


Link to post
Share on other sites

Posted

"Toast" is the word given to the sliding visual cue when an app (typically in the system tray) brings up a window from the tray containing some content (text, links,buttons) and/or plays a sound.

<{POST_SNAPBACK}>

That's the same idea that Firebird uses for update notifications, and Thunderbird uses for new mail notification, if I'm not mistaken on what you are talking about. I think Trillian can use it too (for anyone who uses it that.)

Share this post


Link to post
Share on other sites

Posted

Oh I think it should no problem to create a little 'helper gui' that pops up in the corner :ph34r:

Share this post


Link to post
Share on other sites

Posted

Oh I think it should no problem to create a little 'helper gui' that pops up in the corner :ph34r:

<{POST_SNAPBACK}>

I don't think that would be hard, but the notice that comes out, whatever the "proper" name for it is, takes on the look and style of the OS. Plus, if you have your system menu on the top or side of your screen, I believe the notification also originates from the systray corner.

I think flyingboz wanted a way to access this system ability through AutoIt.

Share this post


Link to post
Share on other sites

Posted

Sorry for bumping such old topics, but has anyone created a thing like this yet?

Share this post


Link to post
Share on other sites

Posted

I got the attachment from Erwin. He got it from somewhere in the forum here.

Try to run that and see if anything does ur thing.

Since I can't seem to attach anything, here's the code: (Copy the code in an new au3 file and run it :whistle: )

;Animate Display *nice* addition
; Author Raindancer

$hwnd = GUICreate("Animate Window", 300, 200)
GUICtrlCreateLabel("Fantasic... You Have PASSED!!!", 50, 50, 200, 50)
GUICtrlSetFont( -1, 16, 800)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00080000);fade-in
GUISetState()
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 1000, "long", 0x00090000);fade-out
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040001);slide in from left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050002);slide out to left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040002);slide in from right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050001);slide out to right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040004);slide-in from top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050008);slide-out to top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040008);slide-in from bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050004);slide-out to bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040005);diag slide-in from Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x0005000a);diag slide-out to Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040006);diag slide-in from Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050009);diag slide-out to Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040009);diag slide-in from Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050006);diag slide-out to Bottom-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x0004000a);diag slide-in from Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00050005);diag slide-out to Bottom-right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 500, "long", 0x00040010);explode
Sleep(1000)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 5000, "long", 0x00050010);implode

#define AW_HOR_POSITIVE            0x00000001
#define AW_HOR_NEGATIVE            0x00000002
#define AW_VER_POSITIVE            0x00000004
#define AW_VER_NEGATIVE            0x00000008
#define AW_CENTER                  0x00000010
#define AW_HIDE                    0x00010000
#define AW_ACTIVATE                0x00020000
#define AW_SLIDE                   0x00040000
#define AW_BLEND                   0x00080000

Share this post


Link to post
Share on other sites

Posted

Hi,

something like this?

#include <GUIConstants.au3>
#include <Color.au3>
Opt("GuiOnEventMode",1)
Dim $Label
Dim $move, $Xpos, $Ypos, $TrayWnd, $Xexit, $Yexit
Dim $iStartColor = 0x0000ff, $iEndColor = 0xffffff
Dim $iSize = -1, $iWeight = -1, $iAttribute = 4, $iFontName = -1
Dim $Clicked = 0
Dim $iWinWidth = 100, $iWinHeight = 100

;========== Test
_SetPopupBackground(0xffff00, 0xffffff)
$Ret = _Popup("MyPopup", "You have 3 mails", 3000)
if $Ret = 0 Then
    $Mensa = "Time out"
ElseIf $Ret = -1 Then
    $Mensa = "Exit Pressed"
Else
    $Mensa = "Seleccionado " & $Ret
EndIf
MsgBox(0,"Test", $Mensa,2)
Exit

;========= End Test

;===============================================================================
;
; Function Name:    _SetPopupSize()
; Description:      Set the size of the Popup Window
;
; Parameter(s):     $WinWidth       - Popup window width
;                   $WinHeight      - Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):        GioVit <gvitale@cantv.net>
;
;===============================================================================



Func _SetPopupSize($WinWidth, $WinHeight)
    $iWinWidth = $winWidth
    $iWinHeight = $WinHeight
EndFunc


;===============================================================================
;
; Function Name:    _SetPopupBackround()
; Description:      Set the Attributes of the font the Hyperlink Label
;
; Parameter(s):     $Size            - Font size
;                   $Weight            - Font weight
;                    $Attibutes        - Font Attributes
;                    $FontName        - Self explanatory
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):        GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _SetPopupFont($Size, $Weight= - 1, $Attribute = 4, $FontName = -1)
    $iSize = $Size
    $iWeight = $Weight
    $Attribute = Bitor($Attribute, 4)
    $iAttribute = $Attribute
    $iFontName = $FontName
EndFunc

;===============================================================================
;
; Function Name:    _SetPopupBackround()
; Description:      Set the Popup Window gradient colors
;
; Parameter(s):     $StartColor        - Popup window width
;                   $EndColor        - Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):        GioVit <gvitale@cantv.net>
;
;===============================================================================


Func _SetPopupBackground($StartColor, $EndColor)
    $iStartColor = $StartColor
    $iEndColor = $EndColor
EndFunc

;===============================================================================
;
; Function Name:    _Popup()
; Description:      Display a sliding popup window from the taskbar displaying a Clickable Control Label
;
; Parameter(s):     $Title            - A window Title (Not Shown)
;                   $Message        - The Clickable text displayed in the window
;                    $Timeout        - [optional] Timeout in miliseconds. After the timeout has elapsed the popup window will be automatically closed.
;
; Requirement(s):   None
; Return Value(s):  -1 = Exit Button was Clicked
;                    0  = Timeout elapsed
;                    1  = Message was Clicked
;
; Author(s):        GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _Popup($Title, $Message, $Timeout = 3000)
    $OldEventMode = AutoItSetOption("GuiOnEventMode",1)
    $PreviousMode = AutoItSetOption("WinTitleMatchMode", 4)
    $TrayWnd = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $PreviousMode)    
    $pos = ControlGetPos("Program Manager", "", "SysListView321")
    $x = $pos[0]
    $y = $pos[1]
    $w = $pos[2]
    $h = $pos[3]
    
    If $TrayWnd[1] > 0 Then
        $move = "Up"
        $Xpos = @DesktopWidth - $iWinWidth - 10
        $Ypos = $TrayWnd[1]
        $Xexit = 4
        $Yexit = 4
    Elseif $TrayWnd[0] > 0 Then
        $move = "Left"
        $Xpos = $TrayWnd[0]
        $Ypos = @DesktopHeight - $iWinHeight - 10
        $Xexit = 4
        $Yexit = 4
    ElseIf $TrayWnd[2] = @DesktopWidth Then
        $move = "Down"
        $Xpos = @DesktopWidth - $iWinWidth - 10
        $Ypos = $TrayWnd[1] + $TrayWnd[3] - $iWinHeight
        $Xexit = 4
        $Yexit = $iWinHeight - 19
    ElseIf $TrayWnd[3] = @DesktopHeight Then
        $move = "Right"
        $Xpos = $TrayWnd[0] + $TrayWnd[2] - $iWinWidth
        $Ypos = @DesktopHeight - $iWinHeight - 10
        $Xexit = $iWinWidth - 19
        $Yexit = 4
    EndIf
            
    $handle = GUICreate($Title, $iWinWidth, $iWinHeight, $Xpos, $Ypos, $WS_POPUPWINDOW,$WS_EX_TOOLWINDOW);$WS_SIZEBOX + $WS_POPUPWINDOW)
    _GUICtrlCreateGradient($iStartColor, $iEndColor, 1, 1, $iWinWidth, $iWinHeight,"H")
    $Label = _GuiCtrlCreateHyperlink($Message, 5, 24, $iWinWidth - 10, $iWinHeight - 48, 0x000000, 'Click Here', BitOR($GUI_SS_DEFAULT_LABEL, $SS_CENTER))
    GuiCtrlSetOnEvent($Label,"_Label")

    $EXIT = GUICtrlCreatePic ("exit.jpg",$Xexit, $Yexit,15,15,0x0100 )

    GUICtrlSetTip(-1, "Exit")
    GuiCtrlSetOnEvent($Exit,"_Exit")

    GUISetState(@SW_SHOW)
    ShowPopup($Title, $move)
    $i = 1
    while $i*10 < $Timeout
        Sleep(10)
        $i += 1
        if $Clicked Then ExitLoop
    WEnd
    HidePopup($Title, $move)
    AutoItSetOption("GuiOnEventMode", $OldEventMode)
    Return $Clicked
EndFunc

Func ShowPopup($Title, $move)
    Select
    Case $move = "Down"
        GUIMove($Title, 0, $iWinHeight)
    Case $move = "Up"
        GUIMove($Title, 0, -$iWinHeight)
    Case $move = "Left"
        GUIMove($Title, -$iWinWidth, 0)
    Case $move = "Right"
        GUIMove($Title, $iWinWidth, 0)
    EndSelect
EndFunc

Func HidePopup($Title, $move)
    $Pxy = WinGetPos($Title)
    Select
    Case $move = "Down"
        GUIMove($Title, 0, -$Pxy[1]-$Pxy[3], 400, False)
    Case $move = "Up"
        GUIMove($Title, 0, @DesktopHeight-$Pxy[1], 400, False)
    Case $move = "Left"
        GUIMove($Title, @DesktopWidth - $Pxy[0], 0, 400, False)
    Case $move = "Right"
        GUIMove($Title, -$Pxy[0] - $Pxy[2], 0, 400, False)
    EndSelect
EndFunc

Func GUIMove($Title, $Dx=0, $Dy=0, $Time=700, $Showing = True)
Dim $Incx, $Incy, $IncTime, $Offsetx, $Offsety
    $Incx = $Dx/($Time/15)
    $Incy = $Dy/($Time/15)
    $IncTrans = 255/($Time/15)
    $Pxy = WinGetPos($Title)
    $i = 1
    While 1
        if $Showing Then
            WinSetTrans($Title, "", $IncTrans*$i)
        Else
            WinSetTrans($Title, "", 255 - $IncTrans*$i)
        EndIf    
        WinMove($Title,"", $Pxy[0]+$Incx*$i, $Pxy[1]+$Incy*$i)
        Sleep(15)
        if abs($Incx*$i) >= Abs($Dx) and Abs($Incy*$i) >= Abs($Dy) then ExitLoop
        $i += 1
        
    WEnd
EndFunc
Func _Exit()
    $Clicked = -1
EndFunc

Func _Label()
;MsgBox(0,"Info", "Click")
    $Clicked = 1
    Return 1
EndFunc


;===============================================================================
; Others Authors Code
;===============================================================================

;===============================================================================
;
; Function Name:    _GuiCtrlCreateHyperlink()
; Description:      Creates a label that acts as a hyperlink
;
; Parameter(s):     $s_Text       - Label text
;                   $i_Left          - Label left coord
;                   [$i_Top]      - Label top coord
;                    [$i_Width]      - Label width
;                   [$i_Height]      - Label height
;                    [$i_Color]      - Text Color
;                    [$s_ToolTip]  - Hyperlink ToolTip
;                    [$i_Style]      - Label style
;                    [$i_ExStyle]  - Label extended style
;
; Requirement(s):   None
; Return Value(s):  Control ID
;
; Author(s):        Saunders <krawlie@hotmail.com>
;
;===============================================================================

Func _GuiCtrlCreateHyperlink($s_Text, $i_Left, $i_Top, $i_Width = -1, $i_Height = -1, $i_Color = 0x0000ff, $s_ToolTip = '', $i_Style = -1, $i_ExStyle = -1)
    Local $i_CtrlID
    $i_CtrlID = GUICtrlCreateLabel($s_Text, $i_Left, $i_Top, $i_Width, $i_Height, $i_Style, $i_ExStyle)
    If $i_CtrlID <> 0 Then
        GUICtrlSetFont (-1, $iSize, $iWeight, $iAttribute, $iFontName)
        GUICtrlSetImage (-1, "shell32.dll",22)
        GuiCtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetColor(-1, $i_Color)
        GUICtrlSetCursor(-1, 0)
        If $s_ToolTip <> '' Then
            GUICtrlSetTip(-1, $s_ToolTip)
        EndIf
    EndIf
    Return $i_CtrlID
EndFunc;==>_GuiCtrlCreateHyperlink

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth = 255, $nHeight = 20,$s_type="V")
   Local $colorR = _ColorGetRed($nStartColor)
   Local $colorG = _ColorGetGreen($nStartColor)
   Local $colorB = _ColorGetBlue($nStartColor)

   Local $nStepR,$nStepG,$nStepB

   GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
    If(StringUpper($s_type) == "V") Then
        $nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nWidth
        $nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nWidth
        $nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nWidth
        For $i = 0 To $nWidth
            $sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
                GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
            GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
            GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
        Next
    ElseIf(StringUpper($s_type) == "H") Then
        $nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nHeight
        $nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nHeight
        $nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nHeight
        For $i = 0 To $nHeight
            $sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
                GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
            GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
            GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
        Next

    EndIf
    GUICtrlSetState(-1, $GUI_DISABLE)
EndFunc

So long,

Mega

Share this post


Link to post
Share on other sites

Posted

Mega,

YOU DA MAN!

I've been looking for something like this for ages - just didn't know what search terms to use!

Thank you very, very much!

Andy

Share this post


Link to post
Share on other sites

Posted

HI,

glad I could help. :)

So long,

Mega

Share this post


Link to post
Share on other sites

Posted

that is indeed some die hard scripting mega :)

Share this post


Link to post
Share on other sites

Posted

Mega,

One last cheeky question - you wouldn't by any chance have the exit.jpg image around would you?

Regards,

Andy

Share this post


Link to post
Share on other sites

Posted

Mega,

One last cheeky question - you wouldn't by any chance have the exit.jpg image around would you?

Regards,

Andy

Oh, and a tweak. At the moment, the 'toast' seems to steal focus from another window (I'm using toast as a standalone exe that can be called from other apps, as it otherwise interferes with my event handling).

So a simple mod fixed this, and I've also included configurable colours and a simple command line input validation:

; Needs to be compiled as a standalone exe, as it captures event handling - core application will not work whilst the window is active
#NoTrayIcon	; Don't show a tray icon

; Place at the top of your script
$g_szVersion = "Toast v1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

#include <GUIConstants.au3>
#include <Array.au3>
#include <Color.au3>
Opt("GuiOnEventMode",1)
Dim $Label
Dim $move, $Xpos, $Ypos, $TrayWnd, $Xexit, $Yexit
Dim $iStartColor = 0x0000ff, $iEndColor = 0xffffff
Dim $iSize = -1, $iWeight = -1, $iAttribute = 4, $iFontName = -1
Dim $Clicked = 0
Dim $iWinWidth = 100, $iWinHeight = 100
Dim $activeWindow

; Get any command line input
if ubound($CMDLINE) < 4 Then
	msgbox(48, "Toast.exe", "Invalid input")
	Exit
EndIf
If $CMDLINE[0] > 0 Then
	$title = $CMDLINE[1]
	$message = $CMDLINE[2]
	$duration = $CMDLINE[3]
	if ubound($CMDLINE) >= 5 then $iStartColor = "0x" & $CMDLINE[4]
	if ubound($CMDLINE) >= 6 then $iEndColor = "0x" & $CMDLINE[5]	

; Get the title of the current active window
	$activeWindow = WinGetTitle('')
	_SetPopupBackground($iStartColor, $iEndColor)
	$Ret = _Popup($title, $message, $duration)

EndIf
Exit

;========= End Test
#ce
;===============================================================================
;
; Function Name:	_SetPopupSize()
; Description:	  Set the size of the Popup Window
;
; Parameter(s):	 $WinWidth	   - Popup window width
;				   $WinHeight	  - Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================



Func _SetPopupSize($WinWidth, $WinHeight)
	$iWinWidth = $winWidth
	$iWinHeight = $WinHeight
EndFunc


;===============================================================================
;
; Function Name:	_SetPopupBackround()
; Description:	  Set the Attributes of the font the Hyperlink Label
;
; Parameter(s):	 $Size			- Font size
;				   $Weight			- Font weight
;					$Attibutes		- Font Attributes
;					$FontName		- Self explanatory
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _SetPopupFont($Size, $Weight= - 1, $Attribute = 4, $FontName = -1)
	$iSize = $Size
	$iWeight = $Weight
	$Attribute = Bitor($Attribute, 4)
	$iAttribute = $Attribute
	$iFontName = $FontName
EndFunc

;===============================================================================
;
; Function Name:	_SetPopupBackround()
; Description:	  Set the Popup Window gradient colors
;
; Parameter(s):	 $StartColor		- Popup window width
;				   $EndColor		- Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================


Func _SetPopupBackground($StartColor, $EndColor)
	$iStartColor = $StartColor
	$iEndColor = $EndColor
EndFunc

;===============================================================================
;
; Function Name:	_Popup()
; Description:	  Display a sliding popup window from the taskbar displaying a Clickable Control Label
;
; Parameter(s):	 $Title			- A window Title (Not Shown)
;				   $Message		- The Clickable text displayed in the window
;					$Timeout		- [optional] Timeout in miliseconds. After the timeout has elapsed the popup window will be automatically closed.
;
; Requirement(s):   None
; Return Value(s):  -1 = Exit Button was Clicked
;					0  = Timeout elapsed
;					1  = Message was Clicked
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _Popup($Title, $Message, $Timeout = 3000)
	$OldEventMode = AutoItSetOption("GuiOnEventMode",1)
	$PreviousMode = AutoItSetOption("WinTitleMatchMode", 4)
	$TrayWnd = WinGetPos("classname=Shell_TrayWnd")
	AutoItSetOption("WinTitleMatchMode", $PreviousMode)   
	$pos = ControlGetPos("Program Manager", "", "SysListView321")
	$x = $pos[0]
	$y = $pos[1]
	$w = $pos[2]
	$h = $pos[3]
   
	If $TrayWnd[1] > 0 Then
		$move = "Up"
		$Xpos = @DesktopWidth - $iWinWidth - 10
		$Ypos = $TrayWnd[1]
		$Xexit = 4
		$Yexit = 4
	Elseif $TrayWnd[0] > 0 Then
		$move = "Left"
		$Xpos = $TrayWnd[0]
		$Ypos = @DesktopHeight - $iWinHeight - 10
		$Xexit = 4
		$Yexit = 4
	ElseIf $TrayWnd[2] = @DesktopWidth Then
		$move = "Down"
		$Xpos = @DesktopWidth - $iWinWidth - 10
		$Ypos = $TrayWnd[1] + $TrayWnd[3] - $iWinHeight
		$Xexit = 4
		$Yexit = $iWinHeight - 19
	ElseIf $TrayWnd[3] = @DesktopHeight Then
		$move = "Right"
		$Xpos = $TrayWnd[0] + $TrayWnd[2] - $iWinWidth
		$Ypos = @DesktopHeight - $iWinHeight - 10
		$Xexit = $iWinWidth - 19
		$Yexit = 4
	EndIf
		   
	$handle = GUICreate($Title, $iWinWidth, $iWinHeight, $Xpos, $Ypos, $WS_POPUPWINDOW,$WS_EX_TOOLWINDOW);$WS_SIZEBOX + $WS_POPUPWINDOW)
	_GUICtrlCreateGradient($iStartColor, $iEndColor, 1, 1, $iWinWidth, $iWinHeight,"H")
	$Label = _GuiCtrlCreateHyperlink($Message, 5, 24, $iWinWidth - 10, $iWinHeight - 48, 0x000000, 'Click Here', BitOR($GUI_SS_DEFAULT_LABEL, $SS_CENTER))
	GuiCtrlSetOnEvent($Label,"_Label")

	$EXIT = GUICtrlCreatePic ("exit.jpg",$Xexit, $Yexit,15,15,0x0100 )

	GUICtrlSetTip(-1, "Exit")
	GuiCtrlSetOnEvent($Exit,"_Exit")



	GUISetState(@SW_SHOW)

; Put focus back on the main window
	WinActivate ( $activeWindow )


	ShowPopup($Title, $move)
	$i = 1
	while $i*10 < $Timeout
		Sleep(10)
		$i += 1
		if $Clicked Then ExitLoop
	WEnd
	HidePopup($Title, $move)
	AutoItSetOption("GuiOnEventMode", $OldEventMode)
	Return $Clicked
EndFunc

Func ShowPopup($Title, $move)
	Select
	Case $move = "Down"
		GUIMove($Title, 0, $iWinHeight)
	Case $move = "Up"
		GUIMove($Title, 0, -$iWinHeight)
	Case $move = "Left"
		GUIMove($Title, -$iWinWidth, 0)
	Case $move = "Right"
		GUIMove($Title, $iWinWidth, 0)
	EndSelect
EndFunc

Func HidePopup($Title, $move)
	$Pxy = WinGetPos($Title)
	Select
	Case $move = "Down"
		GUIMove($Title, 0, -$Pxy[1]-$Pxy[3], 400, False)
	Case $move = "Up"
		GUIMove($Title, 0, @DesktopHeight-$Pxy[1], 400, False)
	Case $move = "Left"
		GUIMove($Title, @DesktopWidth - $Pxy[0], 0, 400, False)
	Case $move = "Right"
		GUIMove($Title, -$Pxy[0] - $Pxy[2], 0, 400, False)
	EndSelect
EndFunc

Func GUIMove($Title, $Dx=0, $Dy=0, $Time=700, $Showing = True)
Dim $Incx, $Incy, $IncTime, $Offsetx, $Offsety
	$Incx = $Dx/($Time/15)
	$Incy = $Dy/($Time/15)
	$IncTrans = 255/($Time/15)
	$Pxy = WinGetPos($Title)
	$i = 1
	While 1
		if $Showing Then
			WinSetTrans($Title, "", $IncTrans*$i)
		Else
			WinSetTrans($Title, "", 255 - $IncTrans*$i)
		EndIf   
		WinMove($Title,"", $Pxy[0]+$Incx*$i, $Pxy[1]+$Incy*$i)
		Sleep(15)
		if abs($Incx*$i) >= Abs($Dx) and Abs($Incy*$i) >= Abs($Dy) then ExitLoop
		$i += 1
	   
	WEnd
EndFunc
Func _Exit()
	$Clicked = -1
EndFunc

Func _Label()
;MsgBox(0,"Info", "Click")
	$Clicked = 1
	Return 1
EndFunc


;===============================================================================
; Others Authors Code
;===============================================================================

;===============================================================================
;
; Function Name:	_GuiCtrlCreateHyperlink()
; Description:	  Creates a label that acts as a hyperlink
;
; Parameter(s):	 $s_Text	   - Label text
;				   $i_Left		  - Label left coord
;				   [$i_Top]	  - Label top coord
;					[$i_Width]	  - Label width
;				   [$i_Height]	  - Label height
;					[$i_Color]	  - Text Color
;					[$s_ToolTip]  - Hyperlink ToolTip
;					[$i_Style]	  - Label style
;					[$i_ExStyle]  - Label extended style
;
; Requirement(s):   None
; Return Value(s):  Control ID
;
; Author(s):		Saunders <krawlie@hotmail.com>
;
;===============================================================================

Func _GuiCtrlCreateHyperlink($s_Text, $i_Left, $i_Top, $i_Width = -1, $i_Height = -1, $i_Color = 0x0000ff, $s_ToolTip = '', $i_Style = -1, $i_ExStyle = -1)
	Local $i_CtrlID
	$i_CtrlID = GUICtrlCreateLabel($s_Text, $i_Left, $i_Top, $i_Width, $i_Height, $i_Style, $i_ExStyle)
	If $i_CtrlID <> 0 Then
		GUICtrlSetFont (-1, $iSize, $iWeight, $iAttribute, $iFontName)
		GUICtrlSetImage (-1, "shell32.dll",22)
		GuiCtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
		GUICtrlSetColor(-1, $i_Color)
		GUICtrlSetCursor(-1, 0)
		If $s_ToolTip <> '' Then
			GUICtrlSetTip(-1, $s_ToolTip)
		EndIf
	EndIf
	Return $i_CtrlID
EndFunc;==>_GuiCtrlCreateHyperlink

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth = 255, $nHeight = 20,$s_type="V")
   Local $colorR = _ColorGetRed($nStartColor)
   Local $colorG = _ColorGetGreen($nStartColor)
   Local $colorB = _ColorGetBlue($nStartColor)

   Local $nStepR,$nStepG,$nStepB

   GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
	If(StringUpper($s_type) == "V") Then
		$nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nWidth
		$nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nWidth
		$nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nWidth
		For $i = 0 To $nWidth
			$sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
				GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
			GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
			GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
		Next
	ElseIf(StringUpper($s_type) == "H") Then
		$nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nHeight
		$nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nHeight
		$nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nHeight
		For $i = 0 To $nHeight
			$sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
				GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
			GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
			GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
		Next

	EndIf
	GUICtrlSetState(-1, $GUI_DISABLE)
EndFunc

Call via

toast.exe "title" "message" duration-in-milliseconds "startcolor" "endcolor"

Where the colors are in RGB hex, eg "ffffff" for white, "ff0000" for red, etc. The code adds the "0x" to the front for autoit to interpret correctly.

Regards,

Andy

Share this post


Link to post
Share on other sites

Posted

Another update, to add font color.

Call via

toast.exe "title" "message" duration-in-milliseconds "startcolor" "endcolor" "fontcolor"

startcolor, endcolor, and fontcolor are optional

; Needs to be compiled as a standalone exe, as it captures event handling - core application will not work whilst the window is active
#NoTrayIcon	; Don't show a tray icon

; Place at the top of your script
$g_szVersion = "Toast v1.0"
If WinExists($g_szVersion) Then Exit; It's already running
AutoItWinSetTitle($g_szVersion)

#include <GUIConstants.au3>
#include <Array.au3>
#include <Color.au3>
Opt("GuiOnEventMode",1)
Dim $Label
Dim $move, $Xpos, $Ypos, $TrayWnd, $Xexit, $Yexit
Dim $iStartColor = 0x0000ff, $iEndColor = 0xffffff, $iFontColor	
Dim $iSize = -1, $iWeight = -1, $iAttribute = 4, $iFontName = -1
Dim $Clicked = 0
Dim $iWinWidth = 100, $iWinHeight = 100
Dim $activeWindow

; Get any command line input
if ubound($CMDLINE) < 4 Then
	msgbox(48, "Toast.exe", "Invalid input")
	Exit
EndIf
If $CMDLINE[0] > 0 Then
	$title = $CMDLINE[1]
	$message = $CMDLINE[2]
	$duration = $CMDLINE[3]
	if ubound($CMDLINE) >= 5 then $iStartColor = "0x" & $CMDLINE[4]
	if ubound($CMDLINE) >= 6 then $iEndColor = "0x" & $CMDLINE[5]	
	if ubound($CMDLINE) >= 7 then $iFontColor = "0x" & $CMDLINE[6]

; Get the title of the current active window
	$activeWindow = WinGetTitle('')
	_SetPopupBackground($iStartColor, $iEndColor)
	$Ret = _Popup($title, $message, $duration)

EndIf
Exit

;========= End Test
#ce
;===============================================================================
;
; Function Name:	_SetPopupSize()
; Description:	  Set the size of the Popup Window
;
; Parameter(s):	 $WinWidth	   - Popup window width
;				   $WinHeight	  - Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================



Func _SetPopupSize($WinWidth, $WinHeight)
	$iWinWidth = $winWidth
	$iWinHeight = $WinHeight
EndFunc


;===============================================================================
;
; Function Name:	_SetPopupBackround()
; Description:	  Set the Attributes of the font the Hyperlink Label
;
; Parameter(s):	 $Size			- Font size
;				   $Weight			- Font weight
;					$Attibutes		- Font Attributes
;					$FontName		- Self explanatory
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _SetPopupFont($Size, $Weight= - 1, $Attribute = 4, $FontName = -1)
	$iSize = $Size
	$iWeight = $Weight
	$Attribute = Bitor($Attribute, 4)
	$iAttribute = $Attribute
	$iFontName = $FontName
EndFunc

;===============================================================================
;
; Function Name:	_SetPopupBackround()
; Description:	  Set the Popup Window gradient colors
;
; Parameter(s):	 $StartColor		- Popup window width
;				   $EndColor		- Popup window height
;
; Requirement(s):   None
; Return Value(s):  None
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================


Func _SetPopupBackground($StartColor, $EndColor)
	$iStartColor = $StartColor
	$iEndColor = $EndColor
EndFunc

;===============================================================================
;
; Function Name:	_Popup()
; Description:	  Display a sliding popup window from the taskbar displaying a Clickable Control Label
;
; Parameter(s):	 $Title			- A window Title (Not Shown)
;				   $Message		- The Clickable text displayed in the window
;					$Timeout		- [optional] Timeout in miliseconds. After the timeout has elapsed the popup window will be automatically closed.
;
; Requirement(s):   None
; Return Value(s):  -1 = Exit Button was Clicked
;					0  = Timeout elapsed
;					1  = Message was Clicked
;
; Author(s):		GioVit <gvitale@cantv.net>
;
;===============================================================================

Func _Popup($Title, $Message, $Timeout = 3000)
	$OldEventMode = AutoItSetOption("GuiOnEventMode",1)
	$PreviousMode = AutoItSetOption("WinTitleMatchMode", 4)
	$TrayWnd = WinGetPos("classname=Shell_TrayWnd")
	AutoItSetOption("WinTitleMatchMode", $PreviousMode)   
	$pos = ControlGetPos("Program Manager", "", "SysListView321")
	$x = $pos[0]
	$y = $pos[1]
	$w = $pos[2]
	$h = $pos[3]
   
	If $TrayWnd[1] > 0 Then
		$move = "Up"
		$Xpos = @DesktopWidth - $iWinWidth - 10
		$Ypos = $TrayWnd[1]
		$Xexit = 4
		$Yexit = 4
	Elseif $TrayWnd[0] > 0 Then
		$move = "Left"
		$Xpos = $TrayWnd[0]
		$Ypos = @DesktopHeight - $iWinHeight - 10
		$Xexit = 4
		$Yexit = 4
	ElseIf $TrayWnd[2] = @DesktopWidth Then
		$move = "Down"
		$Xpos = @DesktopWidth - $iWinWidth - 10
		$Ypos = $TrayWnd[1] + $TrayWnd[3] - $iWinHeight
		$Xexit = 4
		$Yexit = $iWinHeight - 19
	ElseIf $TrayWnd[3] = @DesktopHeight Then
		$move = "Right"
		$Xpos = $TrayWnd[0] + $TrayWnd[2] - $iWinWidth
		$Ypos = @DesktopHeight - $iWinHeight - 10
		$Xexit = $iWinWidth - 19
		$Yexit = 4
	EndIf
		   
	$handle = GUICreate($Title, $iWinWidth, $iWinHeight, $Xpos, $Ypos, $WS_POPUPWINDOW,$WS_EX_TOOLWINDOW);$WS_SIZEBOX + $WS_POPUPWINDOW)
	_GUICtrlCreateGradient($iStartColor, $iEndColor, 1, 1, $iWinWidth, $iWinHeight,"H")
	$Label = _GuiCtrlCreateHyperlink($Message, 5, 24, $iWinWidth - 10, $iWinHeight - 48, $iFontColor, 'Click Here', BitOR($GUI_SS_DEFAULT_LABEL, $SS_CENTER))
	GuiCtrlSetOnEvent($Label,"_Label")

	$EXIT = GUICtrlCreatePic ("exit.jpg",$Xexit, $Yexit,15,15,0x0100 )

	GUICtrlSetTip(-1, "Exit")
	GuiCtrlSetOnEvent($Exit,"_Exit")



	GUISetState(@SW_SHOW)

; Put focus back on the main window
	WinActivate ( $activeWindow )


	ShowPopup($Title, $move)
	$i = 1
	while $i*10 < $Timeout
		Sleep(10)
		$i += 1
		if $Clicked Then ExitLoop
	WEnd
	HidePopup($Title, $move)
	AutoItSetOption("GuiOnEventMode", $OldEventMode)
	Return $Clicked
EndFunc

Func ShowPopup($Title, $move)
	Select
	Case $move = "Down"
		GUIMove($Title, 0, $iWinHeight)
	Case $move = "Up"
		GUIMove($Title, 0, -$iWinHeight)
	Case $move = "Left"
		GUIMove($Title, -$iWinWidth, 0)
	Case $move = "Right"
		GUIMove($Title, $iWinWidth, 0)
	EndSelect
EndFunc

Func HidePopup($Title, $move)
	$Pxy = WinGetPos($Title)
	Select
	Case $move = "Down"
		GUIMove($Title, 0, -$Pxy[1]-$Pxy[3], 400, False)
	Case $move = "Up"
		GUIMove($Title, 0, @DesktopHeight-$Pxy[1], 400, False)
	Case $move = "Left"
		GUIMove($Title, @DesktopWidth - $Pxy[0], 0, 400, False)
	Case $move = "Right"
		GUIMove($Title, -$Pxy[0] - $Pxy[2], 0, 400, False)
	EndSelect
EndFunc

Func GUIMove($Title, $Dx=0, $Dy=0, $Time=700, $Showing = True)
Dim $Incx, $Incy, $IncTime, $Offsetx, $Offsety
	$Incx = $Dx/($Time/15)
	$Incy = $Dy/($Time/15)
	$IncTrans = 255/($Time/15)
	$Pxy = WinGetPos($Title)
	$i = 1
	While 1
		if $Showing Then
			WinSetTrans($Title, "", $IncTrans*$i)
		Else
			WinSetTrans($Title, "", 255 - $IncTrans*$i)
		EndIf   
		WinMove($Title,"", $Pxy[0]+$Incx*$i, $Pxy[1]+$Incy*$i)
		Sleep(15)
		if abs($Incx*$i) >= Abs($Dx) and Abs($Incy*$i) >= Abs($Dy) then ExitLoop
		$i += 1
	   
	WEnd
EndFunc
Func _Exit()
	$Clicked = -1
EndFunc

Func _Label()
;MsgBox(0,"Info", "Click")
	$Clicked = 1
	Return 1
EndFunc


;===============================================================================
; Others Authors Code
;===============================================================================

;===============================================================================
;
; Function Name:	_GuiCtrlCreateHyperlink()
; Description:	  Creates a label that acts as a hyperlink
;
; Parameter(s):	 $s_Text	   - Label text
;				   $i_Left		  - Label left coord
;				   [$i_Top]	  - Label top coord
;					[$i_Width]	  - Label width
;				   [$i_Height]	  - Label height
;					[$i_Color]	  - Text Color
;					[$s_ToolTip]  - Hyperlink ToolTip
;					[$i_Style]	  - Label style
;					[$i_ExStyle]  - Label extended style
;
; Requirement(s):   None
; Return Value(s):  Control ID
;
; Author(s):		Saunders <krawlie@hotmail.com>
;
;===============================================================================

Func _GuiCtrlCreateHyperlink($s_Text, $i_Left, $i_Top, $i_Width = -1, $i_Height = -1, $i_Color = 0x0000ff, $s_ToolTip = '', $i_Style = -1, $i_ExStyle = -1)
	Local $i_CtrlID
	$i_CtrlID = GUICtrlCreateLabel($s_Text, $i_Left, $i_Top, $i_Width, $i_Height, $i_Style, $i_ExStyle)
	If $i_CtrlID <> 0 Then
		GUICtrlSetFont (-1, $iSize, $iWeight, $iAttribute, $iFontName)
		GUICtrlSetImage (-1, "shell32.dll",22)
		GuiCtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
		GUICtrlSetColor(-1, $i_Color)
		GUICtrlSetCursor(-1, 0)
		If $s_ToolTip <> '' Then
			GUICtrlSetTip(-1, $s_ToolTip)
		EndIf
	EndIf
	Return $i_CtrlID
EndFunc;==>_GuiCtrlCreateHyperlink

Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth = 255, $nHeight = 20,$s_type="V")
   Local $colorR = _ColorGetRed($nStartColor)
   Local $colorG = _ColorGetGreen($nStartColor)
   Local $colorB = _ColorGetBlue($nStartColor)

   Local $nStepR,$nStepG,$nStepB

   GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight)
	If(StringUpper($s_type) == "V") Then
		$nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nWidth
		$nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nWidth
		$nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nWidth
		For $i = 0 To $nWidth
			$sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
				GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
			GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $i, 0)
			GUICtrlSetGraphic(-1, $GUI_GR_LINE, $i, $nHeight)
		Next
	ElseIf(StringUpper($s_type) == "H") Then
		$nStepR = (_ColorGetRed($nEndColor) - $colorR) / $nHeight
		$nStepG = (_ColorGetGreen($nEndColor) - $colorG) / $nHeight
		$nStepB = (_ColorGetBlue($nEndColor) - $colorB) / $nHeight
		For $i = 0 To $nHeight
			$sColor = "0x" & StringFormat("%02X%02X%02X", $colorR+$nStepR*$i, $colorG+$nStepG*$i, $colorB+$nStepB*$i)
				GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff)
			GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
			GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i)
		Next

	EndIf
	GUICtrlSetState(-1, $GUI_DISABLE)
EndFunc

Share this post


Link to post
Share on other sites

Posted

Hi all,

I had problems getting AutoIt to do a popup the way I wanted, so I had someone write a C++ popup that's pretty flexible, ready to use in an AutoIt application I'm giving away in order to build a mailing list of people who might be interested in my other software releases.

I'm making the "toast popup" part available for other people to use in their own applications, but it's not free. It cost me $200 to get the code written, so I'm looking to recoup some of that by selling my executable for a low fee.

If you're interested, you can see more at http://automateyourbusiness.com/toast_popup.php

Regards,

Andy

(NB: My host has had a few issues today, so if you can't get to the site, I apologise. Please try again later).

Share this post


Link to post
Share on other sites

Posted

I was working on something like this myself a while ago, had a few incarnations of it.

This is my most recent: http://www.therks.com/autoit/Toast.au3

You'll also need the following files:

Used by the script: http://www.therks.com/autoit/Toast.html

Include: http://www.therks.com/autoit/udfs/_Animatewindow.au3

Include: http://www.therks.com/autoit/udfs/_TaskbarGetPos.au3

It's unfinished, but maybe it will give someone some ideas.

Share this post


Link to post
Share on other sites

Posted (edited)

I wrote a popup script awhile back that I hadn't posted yet. It used WM_TIMER to make the popup run without stalling the script. It also used an embedded IE obj to add the ability to have background images, gradients fills, links, images (html markup). I seem to remember having the basics working. I think I left off at getting the actions from the IE object (button clicked etc.) . I'll try to dig it up when I get home later if interested.

edit:

I posted it to example scripts here.

Edited by eltorro

Share this post


Link to post
Share on other sites

Posted

its my fault or does it not work correctly ?

i can see the window when it moves onto the desktop and off (after the timeout) ... but it seems invisible when its not moving oO

Share this post


Link to post
Share on other sites

Posted

i can see the window when it moves onto the desktop and off (after the timeout) ... but it seems invisible when its not moving oO

The toast script in post #9 and above worked for me in version 3.2.2.0

When I installed version 3.2.10.0, I got the same problem.

I found it worked when I editing the code:

From: Func GUIMove($guiHandle, $Dx=0, $Dy=0, $Time=700, $Showing = True)

To: Func GUIMove($guiHandle, $Dx=0, $Dy=0, $Time=900, $Showing = True)

Not sure why.

Justin

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0




  • Recently Browsing   0 members

    No registered users viewing this page.