Jump to content
S3cret91

Notifications UDF - Desktop notifications 1.2 (updated Mai 1st)

Recommended Posts

Really nice S3cret91, the end product is really polished.

Thanks, it might be useful!

Share this post


Link to post
Share on other sites

It's very nice, well done!

I'll don't have a use for it (for now) but I'll keep it in my snippets dir.

Thanks!

Share this post


Link to post
Share on other sites

S3cret91,

Very nice.

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

 

Share this post


Link to post
Share on other sites

@S3cret91

Nice UDF.

Welcome to the forum

 

btw.
I'm not sure but I think you are the first member with more likes then post (or at least I do not know any more) ;)

 

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

11

Signature last update: 2018-10-31

Share this post


Link to post
Share on other sites

Thank you.

One thing that I forgot to mention:

In the german AutoIt forum one member had issues with the animation being laggy in the example scripts (and me too for a short period of time, but not anymore). If anyone encounters this issue, please say it. And if someone has an explanation why this may happens: I'm open for advice :)

 

 

1 hour ago, mLipok said:

I'm not sure but I think you are the first member with more likes then post (or at least I do not know any more) ;)

Thats the plan :D

Share this post


Link to post
Share on other sites

Helly friends of cool notifications. Got an update for everyone who is interested in some new stuff.

  • Windows 10: Notifications will be colored as your taskbar by default. Change the taskbar color in windows settings and try it out.
  • Windows 8/8.1: Notifications will be colored as the border color of your active window or if this kind of design is deactivated then black (as it was before)
  • Windows 7 and earlier: Black notifications as before (sry but aero design is uncool)

Big thanks to @nend for figuring that out. Check out his thread here.

Also:

  • Notifications will fade out if animationTime > 0
  • Call own functions when a notification is clicked (see _Notifications_Create parameters and the advanced example)
  • Set own notification sounds using _Notifications_SetSound (mp3 or wav)
  • Close all notifications using _Notifications_CloseAll

 

And there is 1 change:

_Notifications_SetTextColor is now named _Notifications_SetColor because it does not only change the text color but also border + seperating line.

 

I also updated the examples, the GUIMsg and OnEvent example are now simplier and reduced to what matters. The advanced example shows what can be done using the Set-Functions.

 

Have fun, please gimme feedback if you notice bugs.

 

Edited by S3cret91

Share this post


Link to post
Share on other sites

I've tested and it was allready good and now it's perfect, very nice UDF.

Edit:

Is it possible to set cursor if hovered over the close label/button of the notifications window?

If no maybe it's a nice function to build in this UDF?

Edited by nend

Share this post


Link to post
Share on other sites
15 minutes ago, S3cret91 said:

You mean that the mouse gets the icon as if the mouse is hovered over a button?

I could do that I guess.

I mean the same as the command "GUICtrlSetCursor" does.

So if the cursor hovered over the label/button it thange into whatever cursor you set.

Share this post


Link to post
Share on other sites

I won't upload a new version right now, so everyone interested pls add it for yourself for now:

1. Enter this line in line 281:

GUICtrlSetCursor(-1, 0)

 

2. Replace lines 250 and 251 with this:

If $__callFunction <> "" Then   
        $__notificationList[$__notificationCount][4] = GUICtrlCreateLabel("", 0, 0, $__notificationWidth, $__closingButtonTop - 1)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor(-1, 0)
    EndIf

 

Share this post


Link to post
Share on other sites
3 hours ago, S3cret91 said:

I won't upload a new version right now, so everyone interested pls add it for yourself for now:

1. Enter this line in line 281:

GUICtrlSetCursor(-1, 0)

 

2. Replace lines 250 and 251 with this:

If $__callFunction <> "" Then   
        $__notificationList[$__notificationCount][4] = GUICtrlCreateLabel("", 0, 0, $__notificationWidth, $__closingButtonTop - 1)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlSetCursor(-1, 0)
    EndIf

 

Insert the lines and it work perfect, thanks.

Share this post


Link to post
Share on other sites

I love this UDF. It looks great! And I realize I'm responding to a post from 2016, but I'm hoping it's not a completely dead thread.

However, I'm interested in using it in multiple programs, but when I do the messages overlap. There's no way for the programs not to overlap each other when messaging, right? I mean, program A has a message, and then program B has a message, and they overlap. This is different than if a single program does multiple messages, where they'll stack on each other.

Thanks. :)

Share this post


Link to post
Share on other sites
19 hours ago, vernalex said:

I love this UDF. It looks great! And I realize I'm responding to a post from 2016, but I'm hoping it's not a completely dead thread.

However, I'm interested in using it in multiple programs, but when I do the messages overlap. There's no way for the programs not to overlap each other when messaging, right? I mean, program A has a message, and then program B has a message, and they overlap. This is different than if a single program does multiple messages, where they'll stack on each other.

Thanks. :)

Hi @vernalex

a way to go could be to:
1) run the notifications as a standalone server program
2) from your programs (clients) send notifications to the notifications server

Here a very simple example (I've simply modified a bit and adapted the examples from this wonderful post by @bogQ

1) run notifications as a standalone server.

    Compile and run this script first

#include <Notifications.au3>
#include <Array.au3>

Opt("GUIOnEventMode", 1)

_Notifications_Startup()
TCPStartup()
Dim $Socket_Data[1]
$Socket_Data[0] = 0
$Listen = TCPListen(@IPAddress1, 1018, 500)
If @error Then
    ConsoleWrite('!--> TCPListen error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPListen to get more info about this error.' & @CRLF)
    Exit
EndIf

While 1
    For $x = $Socket_Data[0] To 1 Step -1
        $Recv = TCPRecv($Socket_Data[$x], 1000000)
        If $Recv Then
            _Notifications_Create('Client Number ' & $x & ' socket id: ' & $Socket_Data[$x], $Recv)
        EndIf
    Next
    _Accept()
WEnd

Func _Accept()
    Local $Accept = TCPAccept($Listen)
    If $Accept <> -1 Then
        _ArrayAdd($Socket_Data, $Accept)
        $Socket_Data[0] += 1
    EndIf
EndFunc   ;==>_Accept

2) use a way like this from your clients to send notifications.

    Compile and run more instances of this script to send notifications to the server from more clients.

TCPStartup()
; connect to the Notifications server
$Socket = TCPConnect(@IPAddress1, 1018)

If @error Then ; check for connection error
    ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ), look in the help file (on MSDN link) on func TCPConnect to get more info about this error.' & @CRLF)
    Exit
EndIf

While 1
    $Message = InputBox("Notification", "Type Data to send (type bye to end")
    If $Message = "bye" Then Exit

    ; to send and popup a notification use the following command:
    TCPSend($Socket, $Message)
WEnd

 


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

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks for this. The Advanced Example makes me want to ask if you are able to check whether any notifications are remaining?

Edited by Inpho
Missed a word

Share this post


Link to post
Share on other sites
On 5/16/2019 at 10:06 AM, Inpho said:

Thanks for this. The Advanced Example makes me want to ask if you are able to check whether any notifications are remaining?

If instead of just sending simple messages to the server you also want to interact with it, then you need to set a way to allow the client and server to establish a two-way dialogue,
the simple example I posted above is unidirectional so it is only part of this process.
to make the process two-way we should improve the tcp communication part.
Here is a quick and rough example of a possible way to proceed.
save the three sample files NotificationsClient.au3, NotificationsServer.au3, MultiClientsExample.au3 and also notifications.udf in the same folder and then run the MultiClientsExample script.
 
p.s.
don't forget to quit the server when you are done.

save this as NotificationsClient.au3

TCPStartup()
; connect to the Notifications server
Global $Socket = TCPConnect(@IPAddress1, 1018)

If @error Then ; check for connection error
    ; try to run the server
    If FileExists(".\NotificationsServer.au3") Then
        Run(@AutoItExe & " .\NotificationsServer.au3")
    ElseIf FileExists(".\NotificationsServer.exe") Then
        Run(".\NotificationsServer.exe")
    Else
        Exit
    EndIf
    ; give time to server to start
    Sleep(1500)
    ; try connecting again
    $Socket = TCPConnect(@IPAddress1, 1018)
    If @error Then Exit
EndIf

Global $FeedBack = _waitAck()

_ExampleClient()

Func _ExampleClient()

    SRandom(@MSEC)
    ; a random color to identify this client's notifications on the messages stack
    Local $MyColor = Random(0x0f0f0f, 0xffffff, 1)

    ; create a simple gui to 'comunicate' with the server
    GUICreate("Notifications Client-Server demo. [" & $FeedBack & "]", 450, 160, Random(10, @DesktopWidth / 2 - 440, 1), Random(10, @DesktopHeight / 2 - 170, 1))

    ; create some controls on the GUI
    $hMessage = GUICtrlCreateInput('', 10, 10, 430, 20)

    $hButtonSend = GUICtrlCreateButton("Send notification", 10, 40, 430, 50)
    GUICtrlSetBkColor(-1, $MyColor)

    $hButtonCheck = GUICtrlCreateButton("Check pending", 10, 110, 130, 40)
    $hButtonClose = GUICtrlCreateButton("Close all", 160, 110, 130, 40)
    $hButtonQuit = GUICtrlCreateButton("Quit client", 310, 110, 130, 40)

    GUISetState()

    ; main loop
    While 1
        $idMsg = GUIGetMsg()
        Select
            Case $idMsg = $hButtonSend
                ; sice the server executes notifications.au3 raw commands
                ; we send a _Notifications_Create() command with parameters,
                ; parameters MUST be expressed in plain text (sending a variables is not allowed of course)
                $sCommad = '_Notifications_Create("' & $FeedBack & '", "' & GUICtrlRead($hMessage) & '")'

                ; ask server to set BackColor for next message
                TCPSend($Socket, '_Notifications_SetBkColor(' & $MyColor & ')')
                _waitAck()

                ; send notification
                TCPSend($Socket, $sCommad)
                _waitAck()

                ; reset the input field
                GUICtrlSetData($hMessage, '')
                ControlFocus('', '', $hMessage)

            Case $idMsg = $hButtonCheck
                ; a new castom notification command implemented on the server
                TCPSend($Socket, '_Notifications_GetPending()')

                ; wait a response from server
                $iPending = _waitAck()
                MsgBox(0, "Pending", $iPending & ' pending messages')

            Case $idMsg = $hButtonClose
                ; ask server to close all my pending messages
                TCPSend($Socket, '_Notifications_CloseAll()')
                _waitAck()

            Case $idMsg = $hButtonQuit
                ; close all pending messages belonging to this client and quit this client
                TCPSend($Socket, '_Notifications_CloseAll()')
                _waitAck()
                TCPSend($Socket, '_Notifications_Shutdown()')
                _waitAck()
                ExitLoop

        EndSelect
    WEnd

    GUIDelete()
EndFunc   ;==>_ExampleClient

; wait a confirm from server
Func _waitAck()
    Local $sAck
    Do
        $sAck = TCPRecv($Socket, 1000000)
    Until $sAck
    Return $sAck
EndFunc   ;==>_waitAck

 

save this as NotificationsServer.au3

#include <Notifications.au3>
#include <Array.au3>
#include <misc.au3>

_Singleton('NotificationsServer', 0)

Opt("GUIOnEventMode", 1)

_Notifications_Startup()

; we add a new 'column' in the $__notificationList array used by the notifications udf
; so to make room to store also info related to the client's socket that required a notification.
Local $iSockColumn = UBound($__notificationList, 2) + 1
ReDim $__notificationList[0][$iSockColumn]
$iSockColumn -= 1

TCPStartup()
Global $Socket_Data[1] ; a buffer to stack connected clients reference
$Socket_Data[0] = 0

; wait for clients on this port
$Listen = TCPListen(@IPAddress1, 1018, 500)

If @error Then
    ConsoleWrite('!--> TCPListen error number ( ' & @error & ' )' & @CRLF)
    Exit
EndIf

; main loop
While 1
    ; scan all connected client to check for incoming commands
    For $x = $Socket_Data[0] To 1 Step -1
        $Recv = TCPRecv($Socket_Data[$x], 1000000)
        If $Recv Then

            ; 1) search position of the open parenthesis
            $iopen_parenthesis_position = StringInStr($Recv, '(')

            ; 2) get the command on the left of the parenthesis
            $sRecvCommand = StringLeft($Recv, $iopen_parenthesis_position - 1)

            ; 3) parse and execute the received command
            Select

                Case $sRecvCommand = "_Notifications_GetPending"

                    $iPending = 0
                    For $iCallerNotifications = 0 To UBound($__notificationList) - 1
                        $iPending += $__notificationList[$iCallerNotifications][$iSockColumn] = $Socket_Data[$x]
                    Next

                    TCPSend($Socket_Data[$x], String($iPending))

                Case $sRecvCommand = "_Notifications_Create"
                    ; MsgBox(0,0,  $Recv)
                    Execute($Recv)
                    ; keep track of incoming messages's socket
                    $__notificationList[UBound($__notificationList) - 1][$iSockColumn] = $Socket_Data[$x]

                    TCPSend($Socket_Data[$x], "created") ; send an ack to client

                Case $sRecvCommand = "_Notifications_CloseAll"
                    ;   here we close all the caller's notifications

                    For $iCallerNotifications = UBound($__notificationList) - 1 To 0 Step -1
                        If $__notificationList[$iCallerNotifications][$iSockColumn] = $Socket_Data[$x] Then _Notifications_Close($iCallerNotifications)
                    Next

                    TCPSend($Socket_Data[$x], "closed") ; send an ack to client

                Case $sRecvCommand = "_Notifications_Shutdown"
                    ; what this function is intended for?
                    ; here we disconnect caller from the server

                    TCPSend($Socket_Data[$x], "bye") ; send an ack to client

                    TCPCloseSocket($Socket_Data[$x])
                    _ArrayDelete($Socket_Data, $x)
                    $Socket_Data[0] -= 1
                    ExitLoop

                Case Else

                    Execute($Recv)
                    TCPSend($Socket_Data[$x], "done") ; send an ack to client

            EndSelect

        EndIf
    Next
    _Accept() ; check for new clients connection requests
WEnd

; check for new clients connection requests
Func _Accept()
    Local $Accept = TCPAccept($Listen)
    If $Accept <> -1 Then
        _ArrayAdd($Socket_Data, $Accept)
        $Socket_Data[0] += 1
        ; send a feedback to the new client (his sock number)
        TCPSend($Accept, String($Accept))
    EndIf
EndFunc   ;==>_Accept

 

save this as MultiClientsExample.au3  (this simply runs 3 clients)

; just run 3 clients to test
For $i = 1 to 3
    Run(@AutoItExe & " NotificationsClient.au3")
Next

 


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

Share this post


Link to post
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

  • Similar Content

    • By Simpel
      Hi,
      I read the forum rules and the passage "interacting with this website", too. I'm not completely sure whether it would be ok to read out my count of notifications by script (there is no automated login) as I do on a private forum where I am the webmaster. There I once in a minute read out unread posts like this:
      #include <inet.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Local $iTreffer = "" Local $sPause $hGUI = GUICreate('Ungelesen', 55, 20, @DesktopWidth - 166, 0, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW) $hDragLabel = GUICtrlCreateLabel("", 0, 0, 20, 20, -1, $GUI_WS_EX_PARENTDRAG) $hIcon = GUICtrlCreateIcon("shell32.dll", 7, 2, 2, 16, 16) $hTreffer = GUICtrlCreateLabel($iTreffer, 20, 0, 35, 20,$SS_CENTER) GUICtrlSetFont(-1,14) GUISetState(@SW_SHOW) Auslesen_Treffer() GUICtrlSetData($hTreffer, $iTreffer) While 1 $sJetzt = TimerDiff($sPause) If $sJetzt > 60000 Then Auslesen_Treffer() GUICtrlSetData($hTreffer, $iTreffer) EndIf Sleep(100) $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Auslesen_Treffer() $sPause = TimerInit() $source = _INetGetSource("https://xxx.yyyy.de/search.php?search_id=unreadposts") ; your forum here If @error Then $iTreffer = "" Return EndIf $sTreffer = StringRegExp($source, "Die Suche ergab \d*? Treffer", 1) If $sTreffer = "0" Then $iTreffer ="" Return EndIf $sTrimTreffer = StringTrimLeft($sTreffer[0],16) $iTreffer = Number(StringTrimRight($sTrimTreffer, 8)) EndFunc Is it allowed to catch the count of notifications from autoitscript.com that way? I always log in personally by website.
      As I looked into the html source code of autoitscript.com I couldn't find something like the count of notifications. Where could I find it?
      If my post is against the rules, I apologize, and I would delete the post immediatly.
      Regards, Conrad
    • By kcvinu
      Hi all,
      For last few weeks, i am in search of some good articles about windows messages and notifications. I am reading Charles Petzold's Windows Programming 5th edition in google books. Since the prize of that book costs nearly my two day's wages, i am depending google books. Then i wandered a lot of websites for gathering articles. Atlast i found a tool on MSDN site. Name is Control Spy. At first i thought that it is like the WindowInfo tool in AutoIt. But no, it is an incredible tool for a develepor. We can learn more about the behaviour of window controls and their messages and notifications. 
      This is the link
      https://www.microsoft.com/en-us/download/details.aspx?id=4635
      After installation, go to the directory and there is a word document. Read and learn more about how a windows control behaves. 
       

    • By dieterhatn
      Hello there!
      I've recently updated to Windows 10 and saw that new and beatiful info center for notifications.
      A lot of applications already support it, so I'm curious if I can get my autoit script to use the windows native notification system.
      Any help is much appreciated
      Thanks in advance
    • By mLipok
      Is there any possibility how to make the notification features such as: sorting, grouping, filtering   e.g. sort by date, name, thread, a notification type grouping by date, name, thread, a notification type filtering, only one date, a name, a thread, a notification type       I think it would help many members manage the information coming every day.
    • By mLipok
      I read many threads.
      I follow to many of them.
      Very often I have that problem.
      I open Notification / VIew All Notifications
      Browser open in new tab - Saved Notifications - a list.
      So I click right mouse button and selecting "Open in new tab"
      And here I expect it will get a specific page that is relevant topic. Well, it happens. But why did not always open the page is not open to the right post? For example, if I have 10 responses to a post I want to open the first answer. So I click on the first visit, and in the meantime opened last.  
×
×
  • Create New...