Jump to content

Recommended Posts

  • Moderators
Posted

Mat,

You want it, you write it! :D

Seriously, if I need user interaction I tend to use a MsgBox (or one of my own ExtMsgBox) and centre it on the app that needs the information. I use Toasts more for passing information to the user - "Indexing, please be patient", "The playing track is...." sort of stuff.

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

 

Posted

kk, Well what about icon support? Proof of concept (you will probably want to rewrite it though :D )

; #FUNCTION# =========================================================================================================
; Name...........: _Toast_Show
; Description ...: Shows a slice message from the systray
; Syntax.........: _Toast_Show($nIcon, $sTitle, $sMessage, [$iDelay [, $fWait]])
; Parameters ....: $nIcon    - The icon to show. Default (0) is none. Can be on of the following:
;                            |1 - App window
;                            |2 - Warning triangle
;                            |3 - Question mark
;                            |4 - Stop sign
;                            |5 - Info sign
;                            |6 - Security sign (Vista+)
;                  $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
; 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
; Author ........: Melba23, based on some original code by GioVit for the Toast, Prog@ndy and Zedna for the [X]
; Notes .........; Any visible Toast is retracted by a subsequent _Toast_Hide or _Toast_Show, or clicking a visible [X]
; Example........; Yes
;=====================================================================================================================

_Toast_Show(6, "test", "this is a test" & @CRLF & @CRLF & "And yet another test!")
Sleep(10000)

Func _Toast_Show($nIcon, $sTitle, $sMessage, $iDelay = 0, $fWait = True)

    ; 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

    ; Get message label size
    Local $aLabel_Pos = _StringSize($sMessage, $iToast_Font_Size, Default, Default, $sToast_Font_Name, $iToast_Width_max - 20)

    ; 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
    If $iToast_Width < $iToast_Width_min Then
        ; Increase if below min size
        $iToast_Width = $iToast_Width_min
        $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 = 5
    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

    If $nIcon <> 0 Then $iToast_Width += 34

    ; 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

    ; 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("T", $iToast_Width - 18, $iX_YCoord, 17, 17)
                GUICtrlSetFont(-1, 14, Default, Default, "Wingdings 2")
                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("T", $iToast_Width - 18, 0, 17, 17)
                GUICtrlSetFont(-1, 14, Default, Default, "Wingdings 2")
                GUICtrlSetBkColor(-1, -2) ; $GUI_BKCOLOR_TRANSPARENT
                GUICtrlSetColor(-1, $iToast_Message_Col)
        EndIf

    EndIf

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

    If $nIcon >= 6 Then $nIcon = 7
    If $nIcon <> 0 Then GUICtrlCreateIcon("user32.dll", -$nIcon, 2, ($iToast_Height - 32) / 2)

    ; 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

        ; 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

Maybe custom icons...

Posted

Why is the close label created with the text "T"? I mean, shouldn't it be "[X]"? But If I change it then it is too far to the right and the ']' is missing, but if I move it to the left and reduce the title bar with to suit then the "]" is still missing, so over to you Melba23.

But more to the point, very nice script Melba23, thanks for 'donating' :D.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
  • Moderators
Posted

martin,

Why is the close label created with the text "T"?

The close label is created with character 0x54 from the WingDing 2 font (an X in a box) which I have translated as "T". If you replace the "T" with "[X]" it is hardly surprising that you cannot fit it in as the position is hardcoded for that character in that font in 14pt. :D

Do you not get the WingDings "X in a box" character when you run the script?

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

 

  • Moderators
Posted (edited)

Mat,

You wanted icons, you got icons: :D

; See first post

M23

Edit: Clear up - see first post for latest version

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

 

Posted

:D

Have you tried this?

_Toast_Show(16, "testing!", "This is a test")
Sleep (1000)

I get a slight overlap with the taskbar, so you need to offset it by about 2px.

One more thing. You should use OnAutoitExitRegister to fade out the control before the program exits. Then I think I'll have difficulty complaining about anything!

Great work though, Have you seen the GMail notifier? I have a plan to do something similar with the autoit forums. You can be very sure that this is project is going to play a big part in that!

Posted

WoW.Thank You MASTER M23.Great Job.

It works without any problems on my OS too:

Microsoft Windows XP Professional

5.1.2600 Service Pack 2 (ru) 2600

Thank you again Melba23 for Great Job.

Congrats.

[size="5"] [/size]
Posted

Do you not get the WingDings "X in a box" character when you run the script?

M23

No, I get a 'T' which is why I tried to change it (I thought maybe it was for Toast!). I hadn't noticed that you had used WingDings 2, maybe I don't have that font. I'll have a look when I start my laptop up again.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
  • Moderators
Posted

Mat,

Have you tried this?

Yes and it is fixed in the post above. :D

I get a slight overlap with the taskbar, so you need to offset it by about 2px

This is something I have tried to fix for a long time and given up on. On my 3 machines (a desktop and 2 laptops all running Vista but with different display resolutions) I could not find one solution to the Toast position coordinates which gives absolute satisfaction on all 3 - there was always one of them where the Toast was slightly high or low. So in the end I have gone with the coordinates that work best on my desktop. If you can solve it, please let me know. :huggles:

One more thing. You should use OnAutoitExitRegister to fade out the control before the program exits.

If you quit when a Toast is showing, the Toast vanishes - that is good enough for me! :

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

 

Posted

Thanks again Melba, I hope that you will continue to spend a fair amount of time on the examples section of the forum, it seems you are spending way to long in General help and support when you could be doing stuff like this!

  • Moderators
Posted (edited)

JohnOne,

Is that because you do not have the WingDings 2 font in Win 7? If so , could you please look in Character Map (or whatever the Win 7 equivalent is) and see if there is another font with an "X in a box" character that could be used instead.

Thanks in advance. :D

M23

Edit: All is now clear - see post below

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

 

Posted

Hi, (pêche) Melba!

could you please look in Character Map (or whatever the Win 7 equivalent is) and see if there is another font with an "X in a box" character that could be used instead.

If MS-office is installed, Arial-Unicode-MS is present, with more than 25 000 different chars...

Or... you can see DaFont

  • Moderators
Posted

Hi all,

A bit of investigation shows that WingDings 2 is NOT a basic installed font - it is installed by any number of MS products, but does not come as standard with any Windows OS.

So I have changed the above posts to use a similar character from WingDings - this font IS installed as standard with all Windows OSs - and adjusted one constant to get the correct display. The character is not quite as nice to look at, but at least everyone will see the same thing. :D Unless they have uninstalled WingDings - and then I refuse all responsibility!

Apologies for the confusion, but I have never seen a machine without both WingDings fonts - some of you must be very resistant to Bill Gates' marketing dept! :huggles:

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

 

Posted (edited)

JohnOne,

Is that because you do not have the WingDings 2 font in Win 7? If so , could you please look in Character Map (or whatever the Win 7 equivalent is) and see if there is another font with an "X in a box" character that could be used instead.

Thanks in advance. :D

M23

In the character map of wingdings, it says "Character code: 0x78"

bog standard installation, with no office .

Not wingdings 2 either.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

Great stuff, thanks for sharing.

Works a treat

Win 7 (32)

I also have the T instead of the wingding, it took me about 1 microsecond to get over it.

Cheers.

That's several thousand times faster than it took me to fail! How did you get over it?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
  • Recently Browsing   0 members

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