Jump to content

Autoit notifications do not stay in Windows 11 notification centre


Go to solution Solved by Melba23,

Recommended Posts

Posted

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.

  • Moderators
Posted

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:

  Reveal hidden contents

 

Posted

@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!

Posted

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

 

Posted

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!

  • Moderators
  • Solution
Posted

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:

  Reveal hidden contents

 

Posted

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

  • Moderators
Posted

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:

  Reveal hidden contents

 

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

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.

Posted
  On 3/20/2024 at 8:54 AM, Chazg said:

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

Expand  
  On 3/20/2024 at 4:20 PM, 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...

Expand  

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

Posted

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

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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

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