Jump to content

Recommended Posts

  • Moderators
Posted

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

 

Posted (edited)

@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:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor 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 * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

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 * SciTE - Lexer for console pane

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 * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

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 TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

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 *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

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

Signature last update: 2023-04-24

Posted

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

Posted (edited)

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
Posted (edited)

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

Posted

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

 

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

  • 3 years later...
Posted

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

Posted
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

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

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

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

  • 10 months later...
Posted

This is an excellent program and I would like to use it.  I need to know how to modify it so I can have the notifications start at the top right of the screen.  Then have subsequent notifications be created below the last one.  Can you please tell me which lines of code I need to modify?

 

Thanks in advance,

Wizardry

Posted

I just wanted to thank you for the BEST Notifications UDF I'VE EVER SEEN!!! 

The Examples are like holy good. If you run the three examples you know everything about that UDF! Perfect!

 

You can tell that you made an effort!

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
×
×
  • Create New...