Jump to content

How to make Toast - New version 2 Aug 18


Melba23
 Share

Recommended Posts

beautiful effects!
Excuse me Mr Melba23, just a question (feature request/suggestion)
could  this udf be adapted for tooltips?
something similar to this javascript library as example (http://www.walterzorn.de/en/tooltip/tooltip_e.htm) move mouse to links on that page to see the effects.

Thank You

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

Why not just use, oh I don't know, tooltips for that?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Why not just use, oh I don't know, tooltips for that?

 

yes, use the same nice graphic effects, but in addition of popup out of the Systray, show it as tooltip as well (using short messages and little images of course...... ? just an idea

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

  • Moderators

Pincopanco,

 

could this udf be adapted for tooltips?

Quite possibly, but not by me! :D

If you want to use any of the code to develop your own version of that Java library, then feel free - all that really needs to be changed is the location where the Toast is created. ;)

Good luck! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 1 month later...
  • Moderators

pica,

Welcome to the AutoIt forums. :)

If you do not want the animation, just delete the 2 DllCall("user32.dll", "int", "AnimateWindow", ... lines. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

...and in the next version of AutoIt there will be _WinAPI_AnimateWindow().

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

...and in the next version of AutoIt there will be _WinAPI_AnimateWindow().

...and constants to replace all those nasty "magic numbers".

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 months later...

[NEW VERSION] - 20 May 13

 

Added: You can now display an image file as well as an icon.

 

Thanks to careca for the request. ;)

New UDF, example and zip below. :)

 

Previous versions:

[NEW VERSION] - 13 Feb 12

Fixed:

 

Using the [X] to retract a Toast which returned directly to the script meant that the message queue still held the relevant event. If the retraction was followed by a subsequent Toast before the message queue had been cleared, this queued event was likely to be interpreted by AutoIt as a click on the [X] of the new Toast. The UDF now clears the message queue when a Toast pauses the script awaiting user input to prevent AutoIt acting on a queued event.

Running _Toast_Show before an [X] Toast retracted automatically left an Adlib function running which then retracted the subsequent Toast early.

 

Thanks to 1RV34 for reporting the bugs.


New - Toast location code rewritten. Location now correct when Classic display mode selected and if users reset the work area to place additonal toolbars above the TaskBar.

Thanks to jmon and MilesAhead for the reports - and guinness for spotting the problem both times.


There are now 3 versions of this UDF available in this topic:

1. The original version in this post.

2. A version which can produce a colour gradient in the titlebar - you will need Yasheid's WinAPIEx UDF.

3. A version which can also display resources saved within the compiled exe - you will need Zedna's Resources UDF as well.

As my original intention was to offer code which did not require additional UDFs, I am only seriously supporting the original version.

However, as you can see from the above, I am quite happy to help you develop a more advanced version. No guarantees, but if you have a great idea for an additional feature, do let me know.

A forum query about the small pop-ups that some apps produce from the systray led me to create my version of how this can be done.

By the way, I call these small GUIs "Toasts" for obvious reasons! :'(

[NEW] Here is the actual Toast UDF:

#include-once

; #INDEX# ============================================================================================================
; Title .........: Toast
; AutoIt Version : 3.3.2.0 - uses AdlibRegister/Unregister
; Language ......: English
; Description ...: Show and hides slice messages from the systray in user defined colours and fonts
; Author(s) .....: Melba23 - using some code from guinness and MilesAhead in _Toast_Locate
; ====================================================================================================================

;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

; #INCLUDES# =========================================================================================================
#include <StringSize.au3>
#include <GDIPlus.au3>

; #GLOBAL VARIABLES# =================================================================================================
Global $iDef_Toast_Font_Size = _Toast_GetDefFont(0)
Global $sDef_Toast_Font_Name = _Toast_GetDefFont(1)

Global $hToast_Handle = 0
Global $hToast_Close_X = 9999
Global $iToast_Move = 0
Global $iToast_Style = 1 ; $SS_CENTER
Global $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
Global $iToast_Header_BkCol = $aRet[0]
$aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
Global $iToast_Header_Col = $aRet[0]
Global $iToast_Header_Bold = 0
Global $iToast_Message_BkCol = $iToast_Header_Col
Global $iToast_Message_Col = $iToast_Header_BkCol
Global $iToast_Font_Size = $iDef_Toast_Font_Size
Global $sToast_Font_Name = $sDef_Toast_Font_Name
Global $iToast_Timer = 0
Global $iToast_Start = 0
Global $fToast_Close = False

; #CURRENT# ==========================================================================================================
; _Toast_Set:  Sets text justification and optionally colours and font, for _Toast_Show function calls
; _Toast_Show: Shows a slice message from the systray
; _Toast_Hide: Hides a slice message from the systray
; ====================================================================================================================

; #INTERNAL_USE_ONLY#=================================================================================================
; _Toast_Locate:          Find Systray and determine Toast start position and movement direction
; _Toast_Timer_Check:     Checks whether Toast has timed out or closure [X] clicked
; _Toast_WM_EVENTS:       Message handler to check if closure [X] clicked
; _Toast_GetDefFont:      Determine system default MsgBox font and size
; _Toast_ShowPNG:         Set PNG as image
; _Toast_BitmapCreateDIB: Create bitmap
; ====================================================================================================================

; #FUNCTION# =========================================================================================================
; Name...........: _Toast_Set
; Description ...: Sets text justification and optionally colours and font, for _Toast_Show function calls
; Syntax.........: _Toast_Set($vJust, [$iHdr_BkCol, [$iHdr_Col, [$iMsg_BkCol, [$iMsg_Col, [$sFont_Size, [$iFont_Name]]]]]])
; Parameters ....: $vJust     - 0 = Left justified, 1 = Centred (Default), 2 = Right justified
;                                Can use $SS_LEFT, $SS_CENTER, $SS_RIGHT
;                                + 4 = Header text in bold
;                       >>>>>    Setting this parameter to' Default' will reset ALL parameters to default values     <<<<<
;                       >>>>>    All optional parameters default to system MsgBox default values                     <<<<<
;                  $iHdr_BkCol - [Optional] The colour for the title bar background
;                  $iHdr_Col   - [Optional] The colour for the title bar text
;                  $iMsg_BkCol - [Optional] The colour for the message background
;                  $iMsg_Col   - [Optional] The colour for the message text
;                                Omitting a colour parameter or setting it to -1 leaves it unchanged
;                                Setting a colour parameter to Default resets the system colour
;                  $iFont_Size - [Optional] The font size in points to use for the Toast
;                  $sFont_Name - [Optional] The font to use for the Toast
;                       >>>>>    Omitting a font parameter, setting size to -1 or name to "" leaves it unchanged     <<<<<
;                       >>>>>    Setting a font parameter to Default resets the system message box font or size      <<<<<
; Requirement(s).: v3.3.2.0 or higher - AdlibRegister/Unregister used in _Toast_Show
; Return values .: Success - Returns 1
;                  Failure - Returns 0 and sets @error to 1 with @extended set to parameter index number
; Author ........: Melba23
; Example........; Yes
;=====================================================================================================================

Func _Toast_Set($vJust, $iHdr_BkCol = -1, $iHdr_Col = -1, $iMsg_BkCol = -1, $iMsg_Col = -1, $iFont_Size = -1, $sFont_Name = "")

    ; Set parameters
    Switch $vJust
        Case Default
            $iToast_Style = 1; $SS_CENTER
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
            $iToast_Header_BkCol = $aRet[0]
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
            $iToast_Header_Col = $aRet[0]
            $iToast_Message_BkCol = $iToast_Header_Col
            $iToast_Message_Col = $iToast_Header_BkCol
            $sToast_Font_Name = $sDef_Toast_Font_Name
            $iToast_Font_Size = $iDef_Toast_Font_Size
            Return
        Case 0, 1, 2, 4, 5, 6
            $iToast_Style = $vJust
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 1, 0)
    EndSwitch

    Switch $iHdr_BkCol
        Case Default
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
            $iToast_Header_BkCol = $aRet[0]
        Case 0 To 0xFFFFFF
            $iToast_Header_BkCol = Int($iHdr_BkCol)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 2, 0)
    EndSwitch

    Switch $iHdr_Col
        Case Default
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
            $iToast_Header_Col = $aRet[0]
        Case 0 To 0xFFFFFF
            $iToast_Header_Col = Int($iHdr_Col)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 3, 0)
    EndSwitch

    Switch $iMsg_BkCol
        Case Default
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 5) ; $COLOR_WINDOW = 5
            $iToast_Message_BkCol = $aRet[0]
        Case 0 To 0xFFFFFF
            $iToast_Message_BkCol = Int($iMsg_BkCol)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 4, 0)
    EndSwitch

    Switch $iMsg_Col
        Case Default
            $aRet = DllCall("User32.dll", "int", "GetSysColor", "int", 8) ; $COLOR_WINDOWTEXT = 8
            $iToast_Message_Col = $aRet[0]
        Case 0 To 0xFFFFFF
            $iToast_Message_Col = Int($iMsg_Col)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 5, 0)
    EndSwitch

    Switch $iFont_Size
        Case Default
            $iToast_Font_Size = $iDef_Toast_Font_Size
        Case 8 To 72
            $iToast_Font_Size = Int($iFont_Size)
        Case -1
            ; Do nothing
        Case Else
            Return SetError(1, 6, 0)
    EndSwitch

    Switch $sFont_Name
        Case Default
            $sToast_Font_Name = $sDef_Toast_Font_Name
        Case ""
            ; Do nothing
        Case Else
            If IsString($sFont_Name) Then
                $sToast_Font_Name = $sFont_Name
            Else
                Return SetError(1, 7, 0)
            EndIf
    EndSwitch

    Return 1

EndFunc   ;==>_Toast_Set

; #FUNCTION# =========================================================================================================
; Name...........: _Toast_Show
; Description ...: Shows a slice message from the systray
; Syntax.........: _Toast_Show($vIcon, $sTitle, $sMessage, [$iDelay [, $fWait [, $fRaw]]])
; Parameters ....: $vIcon    - 0 - No icon, 8 - UAC, 16 - Stop, 32 - Query, 48 - Exclamation, 64 - Information
;                              The $MB_ICON constant can also be used for the last 4 above
;                              If set to the name of an exe, the main icon of that exe will be displayed
;                              If set to the name of an image file, that image will be displayed
;                              Any other value returns -1, error 1
;                  $sTitle   - Text to display on Title bar
;                  $sMessage - Text to display in Toast body
;                  $iDelay   - The delay in seconds before the Toast retracts or script continues (Default = 0)
;                              If negative, an [X] is added to the title bar. Clicking [X] retracts/continues immediately
;                  $fWait    - True  - Script waits for delay time before continuing and Toast remains visible
;                              False - Script continues and Toast retracts automatically after delay time
;                  $fRaw     - True  - Message is not wrapped and Toast expands to show full width
;                            - False - Message is wrapped if over max preset Toast width
; Requirement(s).: v3.3.1.5 or higher - AdlibRegister/Unregister used in _Toast_Show
; Return values .: Success: Returns 2-element array: [Toast width, Toast height]
;                  Failure: Returns -1 and sets @error as follows:
;                           1 = Toast GUI creation failed
;                           2 = Taskbar not found
;                           4 = When using Raw, the Toast is too wide for the display
;                           3 = StringSize error
; Author ........: Melba23, based on some original code by GioVit for the Toast
; Notes .........; Any visible Toast is retracted by a subsequent _Toast_Hide or _Toast_Show, or clicking a visible [X]
; Example........; Yes
;=====================================================================================================================

Func _Toast_Show($vIcon, $sTitle, $sMessage, $iDelay = 0, $fWait = True, $fRaw = False)

    ; Store current GUI mode and set Message mode
    Local $nOldOpt = Opt('GUIOnEventMode', 0)

    ; Retract any Toast already in place
    If $hToast_Handle <> 0 Then _Toast_Hide()

    ; Reset non-reacting Close [X] ControlID
    $hToast_Close_X = 9999

    ; Set default auto-sizing Toast widths
    Local $iToast_Width_max = 500
    Local $iToast_Width_min = 150

    ; Check for icon
    Local $iIcon_Style = 0
    Local $iIcon_Reduction = 36
    Local $sDLL = "user32.dll"
    Local $sImg = ""
    If StringIsDigit($vIcon) Then
        Switch $vIcon
            Case 0
                $iIcon_Reduction = 0
            Case 8
                $sDLL = "imageres.dll"
                $iIcon_Style = 78
            Case 16 ; Stop
                $iIcon_Style = -4
            Case 32 ; Query
                $iIcon_Style = -3
            Case 48 ; Exclam
                $iIcon_Style = -2
            Case 64 ; Info
                $iIcon_Style = -5
            Case Else
                Return SetError(1, 0, -1)
        EndSwitch
    Else
        Switch StringLower(StringRight($vIcon, 3))
            Case "exe", "ico"
                $sDLL = $vIcon
                $iIcon_Style = 0
            Case "bmp", "jpg", "gif", "png"
                $sImg = $vIcon
        EndSwitch
    EndIf

    ; Determine max message width
    Local $iMax_Label_Width = $iToast_Width_max - 20 - $iIcon_Reduction
    If $fRaw = True Then $iMax_Label_Width = 0

    ; Get message label size
    Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iMax_Label_Width)
    If @error Then
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
        Return SetError(3, 0, -1)
    EndIf

    ; Reset text to match rectangle
    $sMessage = $aLabel_Pos[0]

    ;Set line height for this font
    Local $iLine_Height = $aLabel_Pos[1]

    ; Set label size
    Local $iLabelwidth = $aLabel_Pos[2]
    Local $iLabelheight = $aLabel_Pos[3]

    ; Set Toast size
    Local $iToast_Width = $iLabelwidth + 20 + $iIcon_Reduction
    ; Check if Toast will fit on screen
    If $iToast_Width > @DesktopWidth - 20 Then
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
        Return SetError(4, 0, -1)
    EndIf
    ; Increase if below min size
    If $iToast_Width < $iToast_Width_min + $iIcon_Reduction Then
        $iToast_Width = $iToast_Width_min + $iIcon_Reduction
        $iLabelwidth = $iToast_Width_min - 20
    EndIf

    ; Set title bar height - with minimum for [X]
    Local $iTitle_Height = 0
    If $sTitle = "" Then
        If $iDelay < 0 Then $iTitle_Height = 6
    Else
        $iTitle_Height = $iLine_Height + 2
        If $iDelay < 0 Then
            If $iTitle_Height < 17 Then $iTitle_Height = 17
        EndIf
    EndIf

    ; Set Toast height as label height + title bar + bottom margin
    Local $iToast_Height = $iLabelheight + $iTitle_Height + 20
    ; Ensure enough room for icon if displayed
    If $iIcon_Reduction Then
        If $iToast_Height < $iTitle_Height + 42 Then $iToast_Height = $iTitle_Height + 47
    EndIf

    ; Get Toast starting position and direction
    Local $aToast_Data = _Toast_Locate($iToast_Width, $iToast_Height)

    ; Create Toast slice with $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW style and $WS_EX_TOPMOST extended style
    $hToast_Handle = GUICreate("", $iToast_Width, $iToast_Height, $aToast_Data[0], $aToast_Data[1], 0x80880000, BitOR(0x00000080, 0x00000008))
    If @error Then
        $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)
        Return SetError(1, 0, -1)
    EndIf
    GUISetFont($iToast_Font_Size, Default, Default, $sToast_Font_Name)
    GUISetBkColor($iToast_Message_BkCol)

    ; Set centring parameter
    Local $iLabel_Style = 0 ; $SS_LEFT
    If BitAND($iToast_Style, 1) = 1 Then
        $iLabel_Style = 1 ; $SS_CENTER
    ElseIf BitAND($iToast_Style, 2) = 2 Then
        $iLabel_Style = 2 ; $SS_RIGHT
    EndIf

    ; Check installed fonts
    Local $sX_Font = "WingDings"
    Local $sX_Char = "x"
    Local $i = 1
    While 1
        Local $sInstalled_Font = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", $i)
        If @error Then ExitLoop
        If StringInStr($sInstalled_Font, "WingDings 2") Then
            $sX_Font = "WingDings 2"
            $sX_Char = "T"
        EndIf
        $i += 1
    WEnd

    ; Create title bar if required
    If $sTitle <> "" Then

        ; Create disabled background strip
        GUICtrlCreateLabel("", 0, 0, $iToast_Width, $iTitle_Height)
        GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
        GUICtrlSetState(-1, 128) ; $GUI_DISABLE

        ; Set title bar width to offset text
        Local $iTitle_Width = $iToast_Width - 10

        ; Create closure [X] if needed
        If $iDelay < 0 Then
            ; Create [X]
            Local $iX_YCoord = Int(($iTitle_Height - 17) / 2)
            $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, $iX_YCoord, 17, 17)
            GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
            GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
            GUICtrlSetColor(-1, $iToast_Header_Col)
            ; Reduce title bar width to allow [X] to activate
            $iTitle_Width -= 18
        EndIf

        ; Create Title label with bold text, centred vertically in case bar is higher than line
        GUICtrlCreateLabel($sTitle, 10, 0, $iTitle_Width, $iTitle_Height, 0x0200) ; $SS_CENTERIMAGE
        GUICtrlSetBkColor(-1, $iToast_Header_BkCol)
        GUICtrlSetColor(-1, $iToast_Header_Col)
        If BitAND($iToast_Style, 4) = 4 Then GUICtrlSetFont(-1, $iToast_Font_Size, 600)

    Else

        If $iDelay < 0 Then
            ; Only need [X]
            $hToast_Close_X = GUICtrlCreateLabel($sX_Char, $iToast_Width - 18, 0, 17, 17)
            GUICtrlSetFont(-1, 14, Default, Default, $sX_Font)
            GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
            GUICtrlSetColor(-1, $iToast_Message_Col)
        EndIf

    EndIf

    ; Create icon
    If $iIcon_Reduction Then
        Switch StringLower(StringRight($sImg, 3))
            Case "bmp", "jpg", "gif"
                GUICtrlCreatePic($sImg, 10, 10 + $iTitle_Height, 32, 32)
            Case "png"
                _Toast_ShowPNG($sImg, $iTitle_Height)
            Case Else
                GUICtrlCreateIcon($sDLL, $iIcon_Style, 10, 10 + $iTitle_Height)
        EndSwitch
    EndIf

    ; Create Message label
    GUICtrlCreateLabel($sMessage, 10 + $iIcon_Reduction, 10 + $iTitle_Height, $iLabelwidth, $iLabelheight)
    GUICtrlSetStyle(-1, $iLabel_Style)
    If $iToast_Message_Col <> Default Then GUICtrlSetColor(-1, $iToast_Message_Col)

    ; Slide Toast Slice into view from behind systray and activate
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 1000, "long", $aToast_Data[2])

    ; Activate Toast without stealing focus
    GUISetState(@SW_SHOWNOACTIVATE, $hToast_Handle)

    ; If script is to pause
    If $fWait = True Then

        ; Clear message queue
        Do
        Until GUIGetMsg() = 0

        ; Begin timeout counter
        Local $iTimeout_Begin = TimerInit()

        ; Wait for timeout or closure
        While 1
            If GUIGetMsg() = $hToast_Close_X Or TimerDiff($iTimeout_Begin) / 1000 >= Abs($iDelay) Then ExitLoop
        WEnd

        ; If script is to continue and delay has been set
    ElseIf Abs($iDelay) > 0 Then

        ; Store timer info
        $iToast_Timer = Abs($iDelay * 1000)
        $iToast_Start = TimerInit()

        ; Register Adlib function to run timer
        AdlibRegister("_Toast_Timer_Check", 100)
        ; Register message handler to check for [X] click
        GUIRegisterMsg(0x0021, "_Toast_WM_EVENTS") ; $WM_MOUSEACTIVATE

    EndIf

    ; Reset original mode
    $nOldOpt = Opt('GUIOnEventMode', $nOldOpt)

    ; Create array to return Toast dimensions
    Local $aToast_Data[3] = [$iToast_Width, $iToast_Height, $iLine_Height]

    Return $aToast_Data

EndFunc   ;==>_Toast_Show

; #FUNCTION# ========================================================================================================
; Name...........: _Toast_Hide
; Description ...: Hides a slice message from the systray
; Syntax.........: _Toast_Hide()
; Requirement(s).: v3.3.1.5 or higher - AdlibRegister used in _Toast_Show
; Return values .: Success: Returns 0
;                  Failure: If Toast does not exist returns -1 and sets @error to 1
; Author ........: Melba23
; Example........; Yes
;=====================================================================================================================

Func _Toast_Hide()

    ; If no Toast to hide, return
    If $hToast_Handle = 0 Then Return SetError(1, 0, -1)

    ; Slide Toast back behind systray
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hToast_Handle, "int", 500, "long", $iToast_Move)
    ; Delete Toast slice
    GUIDelete($hToast_Handle)
    ; Set flag for "no Toast"
    $hToast_Handle = 0
    ; Unregister a possible message handler
    GUIRegisterMsg(0x0021, "") ; $WM_MOUSEACTIVATE
    ; Unregister a possible Adlib function
    AdlibUnRegister("_Toast_Timer_Check")
    ; Clear possible flag
    $fToast_Close = False

EndFunc   ;==>_Toast_Hide

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_Locate
; Description ...: Find Systray and determine Toast start position and movement direction
; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
; Parameters ....: $iToast_Width  - required width of slice
;                  $iToast_Height - required height of slice
; Author ........: Melba23 - using some code from guinness and MilesAhead
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show
; ===============================================================================================================================
Func _Toast_Locate($iToast_Width, $iToast_Height)

    Local $tWorkArea

    ; Define return array
    Local $aToast_Data[3]
    ; Determine which struct syntax to use to use
    If @AutoItVersion < "3.3.8.0" Then
        $tWorkArea = DllStructCreate("long Left;long Top;long Right;long Bottom")
    Else
        $tWorkArea = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct")
    EndIf

    ; Check if Taskbar is hidden
    Local $aRet = DllCall("shell32.dll", "uint", "SHAppBarMessage", "dword", 0x00000004, "ptr*", 0) ; $ABM_GETSTATE
    If BitAND($aRet[0], 0x01) Then

        ; Find hidden taskbar
        Local $iPrevMode = Opt("WinTitleMatchMode", 4)
        Local $aTray_Pos = WinGetPos("[CLASS:Shell_TrayWnd]")
        Opt("WinTitleMatchMode", $iPrevMode)
        ; If error in finding systray
        If Not IsArray($aTray_Pos) Then Return SetError(2, 0, -1)

        ; Determine direction of Toast motion and starting position
        If $aTray_Pos[1] > 0 Then
            $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
            $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
            $aToast_Data[1] = $aTray_Pos[1] - $iToast_Height - 2
            $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
        ElseIf $aTray_Pos[0] > 0 Then
            $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
            $aToast_Data[0] = $aTray_Pos[0] - $iToast_Width - 2
            $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
            $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
        ElseIf $aTray_Pos[2] > @DesktopWidth - 70 Then
            $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
            $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
            $aToast_Data[1] = $aTray_Pos[1] + $aTray_Pos[3]
            $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
        ElseIf $aTray_Pos[3] >= @DesktopHeight Then
            $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
            $aToast_Data[0] = $aTray_Pos[0] + $aTray_Pos[2]
            $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
            $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
        EndIf

    Else

        ; Determine available work area ; $SPI_GETWORKAREA = 48
        DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 48, "uint", 0, "ptr", DllStructGetPtr($tWorkArea), "uint", 0)
        If @error Then Return SetError(2, 0, -1)
        Local $aWorkArea[4] = [DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Top"), _
                DllStructGetData($tWorkArea, "Right"), DllStructGetData($tWorkArea, "Bottom")]

        ; Determine direction of Toast motion and starting position
        If $aWorkArea[3] <> @DesktopHeight Then
            $iToast_Move = 0x00050004 ; $AW_SLIDE_OUT_BOTTOM
            $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
            $aToast_Data[1] = $aWorkArea[3] - $iToast_Height - 2
            $aToast_Data[2] = 0x00040008 ; $AW_SLIDE_IN_BOTTOM
        ElseIf $aWorkArea[2] <> @DesktopWidth Then
            $iToast_Move = 0x00050001 ; $AW_SLIDE_OUT_RIGHT
            $aToast_Data[0] = $aWorkArea[2] - $iToast_Width - 2
            $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
            $aToast_Data[2] = 0x00040002 ; $AW_SLIDE_IN_RIGHT
        ElseIf $aWorkArea[1] <> 0 Then
            $iToast_Move = 0x00050008 ; $AW_SLIDE_OUT_TOP
            $aToast_Data[0] = @DesktopWidth - $iToast_Width - 10
            $aToast_Data[1] = $aWorkArea[1]
            $aToast_Data[2] = 0x00040004 ; $AW_SLIDE_IN_TOP
        ElseIf $aWorkArea[0] <> 0 Then
            $iToast_Move = 0x00050002 ; $AW_SLIDE_OUT_LEFT
            $aToast_Data[0] = $aWorkArea[0]
            $aToast_Data[1] = @DesktopHeight - $iToast_Height - 10
            $aToast_Data[2] = 0x00040001 ; $AW_SLIDE_IN_LEFT
        EndIf

    EndIf

    Return $aToast_Data

EndFunc   ;==>_Toast_Locate

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_Timer_Check
; Description ...: Checks whether Toast has timed out or closure [X] clicked
; Syntax ........: _Toast_Locate($iToast_Width, $iToast_Height)
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
; ===============================================================================================================================
Func _Toast_Timer_Check()

    ; Return if timeout not elapsed and [X] not clicked
    If TimerDiff($iToast_Start) < $iToast_Timer And $fToast_Close = False Then Return

    ; Retract slice
    _Toast_Hide()

EndFunc   ;==>_Toast_Timer_Check

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_WM_EVENTS
; Description ...: Message handler to check if closure [X] clicked
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast_Show if the Wait parameter is set to False
; ===============================================================================================================================
Func _Toast_WM_EVENTS($hWnd, $Msg, $wParam, $lParam)

    #forceref $wParam, $lParam
    If $hWnd = $hToast_Handle Then
        If $Msg = 0x0021 Then ; $WM_MOUSEACTIVATE
            ; Check mouse position
            Local $aPos = GUIGetCursorInfo($hToast_Handle)
            If $aPos[4] = $hToast_Close_X Then $fToast_Close = True
        EndIf
    EndIf
    Return 'GUI_RUNDEFMSG'

EndFunc   ;==>_Toast_WM_EVENTS

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_GetDefFont
; Description ...: Determine system default MsgBox font and size
; Syntax ........: _Toast_GetDefFont($iData)
; Parameters ....: $iData - 0 = Font point size, 1 = Font name
; Author ........: Melba23
; Modified.......:
; Remarks .......: This function is used internally by _Toast functions
; ===============================================================================================================================
Func _Toast_GetDefFont($iData)

    ; Get default system font data
    Local $tNONCLIENTMETRICS = DllStructCreate("uint;int;int;int;int;int;byte[60];int;int;byte[60];int;int;byte[60];byte[60];byte[60]")
    DllStructSetData($tNONCLIENTMETRICS, 1, DllStructGetSize($tNONCLIENTMETRICS))
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 41, "int", DllStructGetSize($tNONCLIENTMETRICS), "ptr", DllStructGetPtr($tNONCLIENTMETRICS), "int", 0)
    ; Read font data for MsgBox font
    Local $tLOGFONT = DllStructCreate("long;long;long;long;long;byte;byte;byte;byte;byte;byte;byte;byte;char[32]", DllStructGetPtr($tNONCLIENTMETRICS, 15))
    Switch $iData
        Case 0
            ; Font size as integer
            Return Int((Abs(DllStructGetData($tLOGFONT, 1)) + 1) * .75)
        Case 1
            ; Font name
            Return DllStructGetData($tLOGFONT, 14)
    EndSwitch

EndFunc   ;==>_Toast_GetDefFont

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_ShowPNG
; Description ...: Set PNG as image
; Syntax ........: _Toast_ShowPNG($sImg)
; Parameters ....: $sImg - Path of image file
; Author ........: UEZ
; Modified.......: Melba23
; Remarks .......:
; ===============================================================================================================================
Func _Toast_ShowPNG($sImg, $iTitle_Height)

    _GDIPlus_Startup()
    Local $hPic = GUICtrlCreatePic("", 10, 10 + $iTitle_Height, 32, 32)
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sImg)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", 32, "int", 32, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    Local $hBitmap_Resized = $aResult[6]
    Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBMP_Ctxt, "int", 7)
    _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, 32, 32)
    Local $hHBitmap = _Toast_BitmapCreateDIB($hBitmap_Resized)
    _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, 0x0172, 0, $hHBitmap))
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Resized)
    _GDIPlus_GraphicsDispose($hBMP_Ctxt)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_Shutdown()

EndFunc   ;==>_Toast_ShowPNG

; #INTERNAL_USE_ONLY#============================================================================================================
; Name...........: _Toast_BitmapCreateDIB
; Description ...: Create bitmap
; Syntax ........: _Toast_BitmapCreateDIB($hBitmap)
; Parameters ....: $hBitmap - Handle of bitmap
; Author ........: UEZ
; Modified.......:
; Remarks .......:
; ===============================================================================================================================
Func _Toast_BitmapCreateDIB($hBitmap)

    Local $hRet = 0

    Local $aRet1 = DllCall($ghGDIPDll, "uint", "GdipGetImageDimension", "ptr", $hBitmap, "float*", 0, "float*", 0)
    If (@error) Or ($aRet1[0]) Then Return 0
    Local $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet1[2], $aRet1[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    Local $pBits = DllStructGetData($tData, "Scan0")
    If Not $pBits Then Return 0
    Local $tBIHDR = DllStructCreate("dword;long;long;ushort;ushort;dword;dword;long;long;dword;dword")
    DllStructSetData($tBIHDR, 1, DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 2, $aRet1[2])
    DllStructSetData($tBIHDR, 3, $aRet1[3])
    DllStructSetData($tBIHDR, 4, 1)
    DllStructSetData($tBIHDR, 5, 32)
    DllStructSetData($tBIHDR, 6, 0)
    Local $aRet2 = DllCall("gdi32.dll", "ptr", "CreateDIBSection", "hwnd", 0, "ptr", DllStructGetPtr($tBIHDR), "uint", 0, "ptr*", 0, "ptr", 0, "dword", 0)
    If (Not @error) And ($aRet2[0]) Then
        DllCall("gdi32.dll", "dword", "SetBitmapBits", "ptr", $aRet2[0], "dword", $aRet1[2] * $aRet1[3] * 4, "ptr", DllStructGetData($tData, "Scan0"))
        $hRet = $aRet2[0]
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    Return $hRet
EndFunc   ;==>_Toast_BitmapCreateDIB

There are 3 user functions within the UDF:

1. _Toast_Set: Sets text justification and, optionally, colours and font for Toasts

2. _Toast_Show: Shows the Toast

3. _Toast_Hide: Hides the Toast if it has not retracted automatically

There are pre-set min and max values for Toast width which you can alter if you wish (lines 218-220):

; Set default auto-sizing Toast widths

Local $iToast_Width_max = 500

Local $iToast_Width_min = 150

However, you can override the maximum setting up to the full display width by using the "Raw" parameter.

You will also need an include file (another of my UDFs) to make sure the Toast is large enough to fit the required content. It is included in the zip file below or you can download it from here - just save it as StringSize.au3 in the same folder.

And finally an example script to show it working:

;Example Toast

#include "Toast.au3"

Local $sMsg, $hProgress, $aRet[2]

Local $sAutoIt_Path = StringRegExpReplace(@AutoItExe, "(^.*\\)(.*)", "\1")

$sMsg  = "The message text goes in this area" & @CRLF & @CRLF
$sMsg &= "This Toast uses the System colours and font"

$aRet = _Toast_Show(0, "The Title text goes here", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
_Toast_Hide()

$sMsg  = "This Toast uses colours and font defined in a _Toast_Set call." & @CRLF & @CRLF
$sMsg &= "Subsequent Toasts will use these values until they are reset by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "You can also display a standard icon - or one from an exe as here" & @CRLF & @CRLF
$sMsg &= "The next Toast has a very small message to show the pre-set minimum size"

_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show(@AutoItExe, "User-defined Colours and Bold Header", $sMsg, 10)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
_Toast_Hide()

$aRet = _Toast_Show(0, "", "Tiny", 2)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
_Toast_Hide()

$sMsg  = "These lines are of medium length" & @CRLF & @CRLF
$sMsg &= "The width is set by the longest" & @CRLF & @CRLF
$sMsg &= "No wrapping occurs here" & @CRLF & @CRLF
$sMsg &= "Note increased font size"

_Toast_Set(-1, -1, -1, -1, -1, 15)
$aRet = _Toast_Show(0, "Mid Width", $sMsg, 5)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
_Toast_Hide()

$sMsg  = "This is a long message set to left justified and a much larger font using _Toast_Set" & @CRLF & @CRLF
$sMsg &= "The Toast is automatically set to the maximum preset width and the message text "
$sMsg &= "is wrapped as necessary to fit within the margins of the Toast" & @CRLF & @CRLF
$sMsg &= "The image is a png from the AutoIt folder" & @CRLF & @CRLF
$sMsg &= "The Toast colours and weight have been changed by another _Toast_Set call" & @CRLF & @CRLF
$sMsg &= "Note the closure [X] on the title bar.  This Toast will time out in 30 secs "
$sMsg &= "but clicking the [X] will resume the script immediately"

_Toast_Set(0, -1, 0xFFFF00, 0x00FF00, 0x000000, 15, "Courier New")
$aRet = _Toast_Show($sAutoIt_Path & "Examples\GUI\Torus.png", "Max Width and Normal Header", $sMsg, -30)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
_Toast_Hide()

$sMsg  = "This line is very long to show that you can override the pre-set maximum width with the 'Raw' parameter. "
$sMsg &= "You have to add a few more parameters to the _Toast_Show call but that is a small price to pay"
$sMsg &= @CRLF & @CRLF & "However, the Toast will not display if it does not fit on the screen!"

_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10, "Arial")
$aRet = _Toast_Show(0, "Unwrapped Toast", $sMsg, -20, True, True)
If IsArray($aRet) Then
    ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
    _Toast_Hide()
Else
    MsgBox(0, "Error", "Raw Toast too wide for your screen!")
EndIf


$sMsg  = "Note how Toasts adjust automatically in height to display all of the message "
$sMsg &= "regardless of whether there is a title bar to display, the font used, "
$sMsg &= "the number of lines or whether wrapping occurs" & @CRLF & @CRLF
$sMsg &= "This Toast will retract automatically when the next Toast is called "
$sMsg &= "or when the [X] is clicked"

$aRet = _Toast_Show(0, "", $sMsg, -10)
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)

$sMsg  = "This Toast has several blank lines inserted. "
$sMsg &= "This can be useful if you want to leave space to add other controls, "
$sMsg &= "such as a progress bar, to the Toast once it is displayed" & @CRLF & @CRLF & @CRLF & @CRLF
$sMsg &= "The Toast size is returned by the function so you can calculate "
$sMsg &= "where to place the other controls.  "
$sMsg &= "This example script writes the size in the SciTE console" & @CRLF & @CRLF
$sMsg &= "Note that Toast colours and font have been reset to Default"

_Toast_Set(Default)
$aRet = _Toast_Show(0, "Progress Bar", $sMsg, 0) ; No delay or progress bar will not display immediately
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
$hProgress = GUICtrlCreateProgress(10, 65, $aRet[0] - 20, 20)
For $i = 1 To 100
    GUICtrlSetData($hProgress, $i)
    Sleep(50)
Next
Sleep(5000)
_Toast_Hide()

$sMsg  = "This Toast has the 'Wait' flag set to False. " & @CRLF & @CRLF
$sMsg &= "That means that the script will continue while the Toast is displayed as "
$sMsg &= "as you can see from this counter." & @CRLF & @CRLF
$sMsg &= "Clicking the [X] will retract the Toast immediately but it will "
$sMsg &= "automatically retract after 20 seconds in any event"

_Toast_Set(5, 0xFF00FF, 0xFFFF00, 0x0000FF, 0xFFFFFF, 10)
$aRet = _Toast_Show(32, "Script Continuing", $sMsg, -20, False) ; Delay can be set here because script continues
ConsoleWrite("Toast size: " & $aRet[0] & " x " & $aRet[1] & @CRLF)
$hLabel = GUICtrlCreateLabel("", 267, 98, 15, 15, BitOR(0x1, 0x0200)) ; $SS_CENTER, $SS_CENTERIMAGE
GUICtrlSetBkColor(-1, 0xFFFF00)
$iCount = 0
Do
    $iCount += 1
    GUICtrlSetData($hLabel, StringFormat("%2s", $iCount))
    Sleep(1000)
Until $iCount = 60 Or $hToast_Handle = 0 ; Toast will retract automatically before $iCount = 60

Exit

By the way, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - I was trying to prevent the need for any other include files when I wrote these to prevent bloat. :D

As always, kind comments and constructive criticisms welcome - particularly the former! :)

All files above in zip format:attachicon.gifToast.zip

M23

 

Awesome Melba!!! I tried this UDF and I am very glad to see it working as Charm. Thanks and keep up the good work.

Regards,

Sammyboy

Link to comment
Share on other sites

  • 1 month later...

OK, updated to Windows 7, and balloon tips is not working...this appears to be the replacement.

Anyway to tell the toast window where to open?

Anyway to keep the toast window on top?

These might have been answered, but I did not see it, or I missed it.

Thanks

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

OK, updated to Windows 7, and balloon tips is not working...this appears to be the replacement.

 

Anyway to tell the toast window where to open?

Anyway to keep the toast window on top?

 

These might have been answered, but I did not see it, or I missed it.

 

Thanks

Did you actually read the documentation headers?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

nitekram,

The Toast always opens above the systray (notification area) - there is no option to display it anywhere else. You might like to look at my Notify UDF - that does let you choose which side of the screen and in which direction the notifications appear. :)

The Toast is created with the $WS_EX_TOPMOST extended style - so it should be on top already. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I was reading the parameters (in the header), to see if you could change location - did not see it. I thought it was set to be ontop, but I have a window that went over it and messed up the text. Also because I am using 2 monitors, my toast is not above the systray, but rather on the primary monitor at the very upper left corner.

edit, I also have the start menu (systray) on the secondary monitor, on the bottom

edit2, the graphics card I am using is rather old, and the most resent driver is for 2004 for XP, using that as the Windows 7 drivers - more or less it works, I have seen some issues with an application that is using JAVA, so when I lock my computer, or it times out, that application will crash. I am stating this, as it might be the reason for the text getting messed up

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • Moderators

nitekram,

I will look around the forum and see if I can come up with some double monitor location code - as I have only the one it is not something I have ever really though about. :)

As to the "on top" problem, I can only assume that the other window also had the same style applied - I believe Windows then works on creation order to decide which gets priority. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

nitekram,

I will look around the forum and see if I can come up with some double monitor location code - as I have only the one it is not something I have ever really though about. :)

As to the "on top" problem, I can only assume that the other window also had the same style applied - I believe Windows then works on creation order to decide which gets priority. ;)

M23

 

Thanks, hope you find something on the two monitors. As for the other window, it is not an 'on top' window, as I have other windows that I put on it all the time. Since I have a older machine, I am not too worried about that, and if I can get the toast window to show down near the systray, then no worries anyway.

Also, I did put a time out on that, but it did not remove the window, so I used your _Toast_Hide(). Strange as the toast windows kept the delay and went away after using the _Toast_Hide().

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • Moderators

nitekram,

I will try and come up with some location code for you to test soon - I hope you will not mind running some test code first so I can see what sort of returns you get from a dual monitor setup. ;)

If you post the code you are using I would be happy to try and debug the problem you are having with getting the Toasts to disappear. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I used this:

_Toast_Set(1)
_Toast_Show(0, 'Ticket Number', $aAlertInfo[2], 3)

That did not disappear until after I killed my script, but after I added  _Toast_Hide(), it waited for the 3 seconds and disappeared - I do not mind that, as much as trying to move the toast window down towards the clock.

As for testing, I am working today, until 7:30, and will be working from 730 - 730 tommorrow, so I am yours to use for testing.
 

edit, forgot you have no clue what timezone I am in - eastern or 23:30 gmt, and tomorrow 11:30 gmt - 23:30 gmt

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • Moderators

nitekram,

That code as posted works just fine for me - the Toast appears and waits 3 seconds before disappearing. So I am a bit at a loss as to why it does not appear for you. Is the text you are trying to show likely to be too wide? :huh:

Weather permitting, I should be flying tomorrow morning - I will try and get something cobbled together for tommorrow afternoon, which will be late morning your side of the Atlantic. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...