Jump to content

Autoit notifications do not stay in Windows 11 notification centre


Go to solution Solved by Melba23,

Recommended Posts

Hi,

Since upgrading to Windows 11 a few months ago I am having problems with my AutoIt script notifications.

I have a .exe file compiled with AutoIt that runs on my Windows 11 PC as a background process. The .exe file runs automatic backups of very important data every 3 hours.

The .exe has a tray icon where I can also launch manual backups as required.

Once automatic or manual backups are complete the tray icon displays a message detailing any errors with the backup process. It is here that I am having problems.

The message appears on the screen as normal. In Windows 10, the message stayed in Windows notification centre until it was removed by the user. This was useful if I was away from my PC when the message was initially displayed.

However, in Windows 11 the notifications disappears instantly from the notification centre so if  Ido not see the tray icon notification I dont know if any errors occured during the process.

Is there any way to keep the message in the notification centre until it is dismissed?

Notifications from other apps will appear in the notification centre until dismissed so why not my autoit exe file's notifications?

For a fix I have written the info displayed by the notification to text within the tray icon but would prefer the notification system I had with Windows 10.

I have asked about this on numerous Windows forums but as other notifications work as expected no one can help me with my problem

Any help much appreciated.

Link to comment
Share on other sites

  • Moderators

Chazg,

I cannot help with the Win 11 problem, but using my Notify UDF (the link is in my sig) will offer you an alternative method of displaying the results from your exe.

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

@Nine could you give me an example of how to use ShellNotifyIcon Win32 API to push notifications? I have looked at the documentation but can't get anything to work!

Link to comment
Share on other sites

Normally I would have asked you to show what you have tried, but since I have the example up and ready, here you go :

#NoTrayIcon
#include <APIShellExConstants.au3>
#include <WinAPIShellEx.au3>

Opt("MustDeclareVars", True)

OnAutoItExitRegister(OnAutoItExit)

HotKeySet("{ESC}", Terminate)

Local $hGUI = GUICreate("")

; prepare data
Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA_V4)
$tNOTIFYICONDATA.Size = DllStructGetSize($tNOTIFYICONDATA)
$tNOTIFYICONDATA.hWnd = $hGUI
$tNOTIFYICONDATA.Flags = $NIF_ICON + $NIF_TIP
$tNOTIFYICONDATA.tip = "Test"
$tNOTIFYICONDATA.Version = 4

; create icon
$tNOTIFYICONDATA.ID = 2
$tNOTIFYICONDATA.hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 166, 16, 16)
_WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA)

; push notification
$tNOTIFYICONDATA.Flags = $NIF_INFO
$tNOTIFYICONDATA.Info = "Info 256 bytes"
$tNOTIFYICONDATA.InfoTitle = "Info title 64 bytes"
$tNOTIFYICONDATA.InfoFlags = $NIIF_USER ; user icon
$tNOTIFYICONDATA.hBalloonIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 130, 16, 16)
_WinAPI_ShellNotifyIcon($NIM_MODIFY, $tNOTIFYICONDATA)

While Sleep(100)
WEnd

Func OnAutoItExit()
    ; delete icon
    _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA)
EndFunc   ;==>OnAutoItExit

Func Terminate()
  Exit
EndFunc

 

Link to comment
Share on other sites

Many thanks @Nine, using your example produces exactly the same result as detailed in my original post, that is:

The message appears on the screen and in the notification centre. When the notification disappears it also disapears from the notification centre.

So, if I am not at my PC when the notification is displayed I have no record in the notification centre that the message was there at all! Very annoying!

Link to comment
Share on other sites

  • Moderators
  • Solution

Chazg,

Did you look at my Notify UDF?

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

@Melba23 Ah yes, sorry, didn't get back to you on that one.

Yes, I have taken a look and it works very well in all my tests. I would like to resolve my original problem but after many weeks of trying I don't hold out much hope.

My only current solution is, therefore, to use your UDF, which is great. Many thanks for your help with this.

Link to comment
Share on other sites

  • Moderators

Chazg,

My pleasure - glad you found the UDF useful.

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

Posted (edited)

Thanks for the link. In my tests changing the value of 'Messageduration' changes the time that the message is displayed on the screen. However as before, once the message disappears it disappears completely from the notification centre.

I really don't understand as notifications from other apps are displayed on screen and then once they have disappeared they are visible in the notifications centre until I click on the x to remove them.

I have checked the notifications settings for autoit scripts and they are the same as for those applications that work correctly.

Edited by Chazg
Link to comment
Share on other sites

  • Moderators

Some GUIs have timeout features... Just MsgBox() off the top of my head has that option.  But it's an "option", to force it on someone I don't agree with unless it's necessary for an application to continue running.  At minimum there's a 5 second delay option, but max is 5 minutes unfortunately.  Looks like it's time for you to write a notification pop-up logger 💪👍!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

8 hours ago, Chazg said:

When the notification disappears it also disapears from the notification centre.

47 minutes ago, Nine said:

If someone else has Win11, it would be nice to test my code to see if they observe the same behavior as you...

Yes, it disappears in Win11. Win10 works as expected. 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

I see the same behaviour.
Seems W10/11 does not keep old notifications.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@Nine I tried your notification code and it consistently creates an ownership reg entry on my test box:

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.Explorer.Notification.{EF042132-5191-5B05-CE52-68DCD8D3A677}

Is there a way to create the notification key with a user defined name? 

Previously, I've been using TrayTip() to create the notifications but it creates a different key each run. So I've been enumerating the registry before and after to get the key name.

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