Jump to content

How to make Toast - New version 2 Aug 18


Melba23
 Share

Recommended Posts

MilesAhead,

Not off the top of my head - I will have a think. But this is pretty general problem as I often get overlapping notifications from various third-party apps that are running, so I am not sure it will be that easy. Are all of the apps using my UDF? :huh:

M23

 

It's not something I'm running into.  But now that I am doing AutoIt3 again I anticipate popping up a lot more Toast.  :)

The other thing I found.. I tried polling both the toast close variable and the toast handle as I way to skip an item in a loop.  I have a delayed start type utility and I pop up Toast with a number to show the count down until I fire off the next application.  I could skip easily enough using a default menu item and double clicking the Tray Icon.  But with things loading and the tray icons shifting around I found it much easier to insert a flag variable in the event handler that detects the 'x' is clicked when Wait is False.  I use that to skip a program in the list of delayed applications.  Much more intuitive to close the window to skip the item.  Anyway I thought you may consider it generally useful and perhaps put in a way to get a notification when the 'x' is clicked etc..

Edited by MilesAhead
Link to comment
Share on other sites

For a program to know of others using Toast the only way I could think to implement it would be using RegisterWindowMessage and handling it.  It could be done but kind of messy.  It may be simpler to just allow the user to set a direction param in an ini file.  In my utility I have done it this way by adding optional param $tdir onto _Toast_Show() and _Toast_Locate().  _Toast_Show() just passes the param to _Toast_Locate() so no need to show it.  _Toast_Locate() I just doctor the data and return unless $tdir is 0 in which case it just passes to your code.  The $tdir values 1 to 4 just set Toast to the middle of the work area edge clockwise, 1 being the left edge of work area centered, 2 = top, 3 = right, 4 = bottom etc..

That way if the user sees overlapping Toast (s)he can adjust one of the programs to display it in another spot.

I made this change in _Toast_Locate()

Func _toast_locate($itoast_width, $itoast_height, $tdir = 0)
    Local $atoast_data[3]
    Local $l, $t, $r, $b
    _getdesktopworkarea($l, $t, $r, $b)
    If $tdir = 1 Then
        $atoast_data[0] = $l
        $atoast_data[1] = Round($b / 2)
        $atoast_data[2] = 262145
        $itoast_move = 327682
        Return $atoast_data
    ElseIf $tdir = 2 Then
        $atoast_data[0] = Round($r / 2) - Round($itoast_width / 2)
        $atoast_data[1] = $t
        $atoast_data[2] = 262148
        $itoast_move = 327688
        Return $atoast_data
    ElseIf $tdir = 3 Then
        $atoast_data[0] = $r - $itoast_width
        $atoast_data[1] = Round($b / 2) - Round($itoast_height / 2)
        $atoast_data[2] = 262146
        $itoast_move = 327681
        Return $atoast_data
    ElseIf $tdir = 4 Then
        $atoast_data[0] = Round($r / 2) - Round($itoast_width / 2)
        $atoast_data[1] = $b - $itoast_height
        $atoast_data[2] = 262152
        $itoast_move = 327684
        Return $atoast_data
    EndIf
; if $tdir = 0 falls through to original code
...

To be notified if somebody clicked the 'x' to close Toast I took the expedient of

just checking for my global variable named $skip

Func _toast_wm_events($hwnd, $msg, $wparam, $lparam)
    #forceref $wParam, $lParam
    If $hwnd = $htoast_handle Then
        If $msg = 33 Then
            Local $apos = GUIGetCursorInfo($htoast_handle)
            If $apos[4] = $htoast_close_x Then
                $ftoast_close = True
                If IsDeclared("skip") Then
                    $skip = True ; user closed Toast to skip to next item
                EndIf
            EndIf
        EndIf
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>_toast_wm_events

In my count down loop while Toast is showing I loop 20 times

(for each second in the count down)sleeping for 50 ms and

checking $skip in every loop.  It seems to work well.  Makes

it easy for someone to skip to the next item.  In this case it is

programs loaded at startup after various delays.

Edited by MilesAhead
Link to comment
Share on other sites

  • Moderators

MilesAhead,

Thanks, I will look into the code tomorrow. :)

M23

Edited by Melba23
23k

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 year later...
  • Moderators

R0G,

The Toast is already created with the $WS_EX_TOPMOST style - I am not sure what more you can do if Windows decides to give its creations an even higher z-level.

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

  • 10 months later...
  • Moderators

You,

Currently the UDF has the following options  for the $vIcon parameter:

; 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

What more do you need?

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

  • 2 weeks later...

Was testing some stuff out earlier today and found a possible bug. I have only be able to reproduce it by calling a function with a hotkey.

#include "Toast.au3"

$x = 0

HotKeySet("!d", "ShowToast")
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(100)
WEnd


Func MyFunc()
EndFunc

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func ShowToast()
    $x+= 1

    _Toast_Show(0, "test title", String($x), -2, False)
EndFunc

If you press the hotkey while an existing Toast is retracting, the subsequent Toast disappears immediately.

Link to comment
Share on other sites

  • Moderators

Danp2,

I see the problem - now trying to see why it happens.

M23

Edit: I now know why it happens - looking to see how to prevent it.

Edited by Melba23

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

  • Moderators

Danp2,

The problem is that the Hotkey interrupts the running script and so the running closure code stops while the new Toast is created. This means that when the closure code restarts the new Toast is taken as the current one and is immediately closed. I am trying to get the UDF to recognise this situation, but with no luck as yet. 

I may have to get into a serious rewrite so I hope you are not holding your breath for a solution!

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

  • Moderators

Danp2,

OK, I think I have cracked it. If you call the _Toast_Show function via a HotKey you need to tell the UDF that is what is happening so that it can wait for the current retraction to finish before creating the new Toast. Please try this new version:

<snip>

 

and amend your script as follows:

#include "Toast_Mod.au3"

$x = 0

HotKeySet("!d", "ShowToast")
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(100)
WEnd


Func MyFunc()
EndFunc

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func ShowToast()
    $x+= 1

    _Toast_Show(0, "test title", String($x), -2, False, False, "!d") ; Tell UDF which HotKey has been used to call it <<<<<<<<<<<<<<<<<
EndFunc

It works fine for me - I hope it does for you too.

M23

Edited by Melba23
Beta code removed

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

  • Moderators

Danp2,

Thanks a lot for that suggestion - you are quite right. I had added the @HotKeyPressed check earlier in the debugging process to see if a HotKey had been used to call the function and never thought of checking to see if it was still needed.

An interesting little edge case bug - I will release a new version this weekend.

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

  • Moderators

Danp2,

Quote

making the the animation speed user configurable

You mean like this: <snip>

M23

Edited by Melba23
Beta code removed

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

  • Moderators

Danp2,

No problem - I owe you something for the bug report and code simplification suggestion!

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

  • Moderators

[NEW VERSION] - 1 Apr 17

Added: Ability to set time taken for Toast to extend and retract (default 1.0/.5 sec)

Fixed: An edge case bug where showing a new Toast while the previous was actually retracting caused the new Toast to vanish instantly.

Thanks to Danp2 for the report and feature request.

New UDF and example in the first post.

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