It is currently March 28th, 2024, 11:28 am

Windows Notification Toaster

Skins that control functions in Windows or Rainmeter
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Windows Notification Toaster

Post by kyriakos876 »

Hello,
I haven't seen anything similar (for some reason) so I made a skin that toasts a Windows 10 notification to use it for my skin.

General notification options
NotificationTitle;;Default: Rainmeter ;;
If defined, this variable will be the notification's Title.
If not defined, the NotificationContext will take its place. If neither are defined, the default of each Variable will be displayed.
Example: NotificationTitle=My notification's Title
NotificationContext;;Default: New notification;;
If defined, this variable will be the notification's context.
If not defined, but NotificationTitle is defined, only the Title will be displayed.
Example: NotificationContext=My notification's context
NotificationTopImage;; ;;
If defined, this variable will show an image on the top of the notification.
Image dimensions are 364x180 pixels at 100% scaling.
The image can be sourced either from:
1) local path No size limits.
2) URL For http and https remote web images, there is a limit of 3 MB on normal connections and 1 MB on metered connections on the file size of each individual image. If an image exceeds the file size, or fails to download, or times out, the image will be dropped and the rest of the notification will be displayed.
Example: NotificationTopImage=#@#Images\HeroImage.jfif
Example: NotificationTopImage=https://picsum.photos/360/202?image=1043
NotificationIcon;;Default: Rainmeter's logo;;
If defined, this variable will be the notification's icon.
If not defined, the default will be displayed.
Image dimensions are 48x48 pixels at 100% scaling.
The image can be sourced either from:
1) local path No size limits.
2) URL For http and https remote web images, there is a limit of 3 MB on normal connections and 1 MB on metered connections on the file size of each individual image. If an image exceeds the file size, or fails to download, or times out, the image will be dropped and the rest of the notification will be displayed.
Example: NotificationIcon=#@#Images\appLogoOverride.jfif
Example: NotificationIcon=https://picsum.photos/48?image=883
Progress bar;;Options: (see below);;
NotificationProgressBarTitle: If defined, this variable will be the notification's progress bar title.
Example: NotificationProgressBarTitle=My notification's progress bar title

NotificationProgressBarValue: If defined, this variable will be the notification's progress bar value.
This variable has to be between 0-1.
Example: NotificationProgressBarValue=0.54

NotificationProgressBarValueOverride: If defined, this variable will override the percentage to whatever you want.
If not defined, the actual percentage will be displayed.
You can put anything, numbers and strings.
Example: NotificationProgressBarValueOverride=10/20 songs

NotificationProgressStatus: If defined, this variable will be the notification's progress status.
Example: NotificationProgressStatus=Playing...
Button,Button2,...,Button5;;Options: (See below);;
NotificationButtonName: If defined, this variable will be the buttons name.
Example: NotificationButtonName=Click me
Example: NotificationButtonName2=Don't click me

NotificationButtonIcon: If defined, this variable will show an icon above the button's name.
Example: NotificationButtonIcon=#@#Images\Complete.png
Example: NotificationButtonIcon2=#@#Images\Something.png

NotificationButtonAction: If defined, this variable will execute an action.
This action can either be a local path, a URL, or nothing.
Example: NotificationButtonAction="https://forum.rainmeter.net/viewtopic.php?f=27&t=29933&p=154476#p154476"
Example: NotificationButtonAction2=#@#ShutdownPC.vbs

Note: You can only have up to 5 buttons per notification.
Note: This will work only for windows 10 version 1709 and later.
Note2: You can have a max of 20 notification show in the action center per app.

Changelog:
[8.11.2018.2](Latest)
-Fixed "When you define a new button or a progress bar, the first time you set the variables, a refresh will be needed to properly show the notification. I have an idea for a possible fix, will update." Now you can add buttons and progress bar without refreshing.. (Thanks khanhas again for the idea.)

[8.11.2018]
-Added: "Ask permission to show notification" option. (This writes in the registry but I'm close to finding a solution.)
-Removed: Removed the lua script, now everything is done using PowershellRM plugin (Huge thanks to khanhas and others!)
-Added: Multiple buttons support.
-Changed: You don't need to manually escape XML reserved characters.
-Added: Progress bar support.
-Fixed: Some issues with the script.
-Issue: When you define a new button or a progress bar, the first time you set the variables, a refresh will be needed to properly show the notification. I have an idea for a possible fix, will update.

[4.11.2018]
-Added: button action support and made the notification be called by Rainmeter instead of powershell.
-Minor code changes.

[3.11.2018]
-Made the powershell script run without displaying a powershell window (thanks raiguard)
-Minor code changes.

Finally, if someone is interested enough, you can edit the XML code pretty easily to do more stuff.
Here's some easy-to-follow documentation
...........................
WindowsNotificationToaster_8.11.2018.2.rmskin
(49.68 KiB) Downloaded 983 times
Last edited by kyriakos876 on November 9th, 2018, 5:31 pm, edited 23 times in total.
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

Re: Windows Notification Toaster

Post by raiguard »

This is fantastic! I might end up using this for my suite's update notifications. :D

I found a solution to running it without showing a PowerShell window: Rather than executing the command directly through the SKIN:Bang() function, use the bang to execute a RunCommand measure, like so:

SKIN:Bang('!CommandMeasure', 'MeasureRunCommand', 'Run')

Code: Select all

[MeasureRunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=Powershell -ExecutionPolicy Bypass -File #@#\NotificationToaster.ps1
Now it would be fantastic if I could make the button do something, as well as change the icon (though I don't have much hope for the latter...)

And how would one make it persist in Action Center?
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

raiguard wrote: November 3rd, 2018, 12:48 am This is fantastic! I might end up using this for my suite's update notifications. :D

I found a solution to running it without showing a PowerShell window: Rather than executing the command directly through the SKIN:Bang() function, use the bang to execute a RunCommand measure, like so:

SKIN:Bang('!CommandMeasure', 'MeasureRunCommand', 'Run')

Code: Select all

[MeasureRunCommand]
Measure=Plugin
Plugin=RunCommand
Parameter=Powershell -ExecutionPolicy Bypass -File #@#\NotificationToaster.ps1
woah, I don't believe that I didn't think of running it with RunCommand.... Yea, that works... I'll update the skin.
raiguard wrote: November 3rd, 2018, 12:48 am Now it would be fantastic if I could make the button do something, as well as change the icon (though I don't have much hope for the latter...)

And how would one make it persist in Action Center?
You can make the button do something but that is pretty complicated... You can have it open an app or do something native to windows 10 like shutting down the PC or muting the sound etc.. Anything more than that and you'll need some experience with windows 10.

As for making it persist in the Action Center, doesn't it anyway? For me, it stays in the Action Center until I manually swipe it away.

EDIT: see first post for the buttons actions
Last edited by kyriakos876 on November 5th, 2018, 12:24 am, edited 1 time in total.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

Turns out you can change the icon, just add this in line 15 in the .ps1 script:

Code: Select all

      <image placement="appLogoOverride" hint-crop="circle" src="https://picsum.photos/48?image=883"/>
and then you'll need to change the lua script as well to write accordingly. I will update the skin later so that it supports images.

I will do some stuff and update the first post with a documentation on how to do much more, such as adding a progress bar.

EDIT: This doesn't work for the updated version as of 4/11/2018
Last edited by kyriakos876 on November 3rd, 2018, 10:46 pm, edited 1 time in total.
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

Re: Windows Notification Toaster

Post by raiguard »

kyriakos876 wrote: November 3rd, 2018, 9:45 am As for making it persist in the Action Center, doesn't it anyway? For me, it stays in the Action Center until I manually swipe it away.
It doesn't for me half of the time. The other half of the time, it'll be there the first time I open action center after the notification is sent, but if I close and open action center again, it'll be gone...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Windows Notification Toaster

Post by jsmorley »

raiguard wrote: November 3rd, 2018, 2:56 pm It doesn't for me half of the time. The other half of the time, it'll be there the first time I open action center after the notification is sent, but if I close and open action center again, it'll be gone...
They stay for me, until manually cleared. Subsequent firing just stacks them up in reverse chronological order.

1.jpg
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

Re: Windows Notification Toaster

Post by raiguard »

jsmorley wrote: November 3rd, 2018, 3:05 pm They stay for me, until manually cleared. Subsequent firing just stacks them up in reverse chronological order.


1.jpg
Yeah, that's not at all the case for me. If I let the notification disappear by itself, it clears it out of action center. If I send one multiple times in succession, it will delete the previous instance and replace it with the new one. The only way I can make it persist in Action Center is by clicking the action center button on the taskbar before the notification disappears.

I already tried changing the notification settings for PowerShell, but according to them, it should do as it is doing it for you...

EDIT: ABORT, I WAS WRONG. My settings were NOT configured correctly. Now the notifications are persisting like they should be. Although it bothers me that the default 'apparently' is set to not show them in Action Center.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

raiguard wrote: November 3rd, 2018, 3:20 pm .
.
.
Although it bothers me that the default 'apparently' is set to not show them in Action Center.
I'm pretty sure that this IS the default....
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Windows Notification Toaster

Post by balala »

raiguard wrote: November 3rd, 2018, 12:48 am This is fantastic!
I completely agree with raiguard, this indeed is fantastic. Didn't know about this, but I will use it in the near future.
Thanks for sharing.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Windows Notification Toaster

Post by balala »

As a side note, I'd add that at least as far as I can tell, the TemplateFilePath, the OutputFilePath and the DynamicVariables=1 options of the [MeasureLua] measure are useless. Even removing them, the code still works. In fact for example the Template.inc file (used into the TemplateFilePath option) doesn't even exist.
And one more, not related specifically to this thread, but to many others too: there is no need to include options into quotes. For example you don't need the quotes around the string passed into the Text option of the [MeterString] meter. Instead of Text="Click me to toast a notification", the Text=Click me to toast a notification form of the option works same well. The quoted option also works, but it's not needed.
Very common mistake (if it can be called mistake).
Post Reply