It is currently March 28th, 2024, 4:24 pm

Windows Notification Toaster

Skins that control functions in Windows or Rainmeter
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 »

kyriakos876 wrote: November 4th, 2018, 2:17 pm I'd be glad to contribute. At the moment I'm trying to figure out how to escape the reserved characters in XML automatically. The only thing I can think of right now, is using lua's gsub.
If'd you care to help, it would be something like:

Code: Select all

name = "Hi & goodbye"
name = name:gsub("%&", "&")
This would return "Hi & goodbye"
but I don't know what would the syntax be for more characters... for example, if I had:

Code: Select all

name = "Hi & goodbye. My age is < than yours"
name = name:gsub( ???????? )
What would the gsub be in order to replace & with &amp; AND < with &lt; ?
Just stack them up...

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
MyString=Hello & goodbye < single 'quote' double "quote" > world

[Lua]
Measure=Script
ScriptFile=Test.lua

[MeterEncoded]
Meter=String
MeasureName=Lua
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1

Code: Select all

function Update()

	myString = SKIN:GetVariable('MyString')
	myString = myString:gsub('&', '&amp;')
	myString = myString:gsub('<', '&lt;')
	myString = myString:gsub('>', '&gt;')
	myString = myString:gsub('"', '&quot;')
	myString = myString:gsub("'", '&apos;')
	
	return myString

end
1.jpg

Note: Replace & first...

There shouldn't be that many you have to do, it's mostly just to stop any confusion with XML "reserved" characters, which are more or less & < > ' ".
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

jsmorley wrote: November 4th, 2018, 3:21 pm Just stack them up...

Note: Replace & first...

There shouldn't be that many you have to do, it's mostly just to stop any confusion with XML "reserved" characters, which are more or less & < > ' ".
Oh okay, so I can't put it all in the same... Kinda makes sense because if you replace < with &lt; and then if you replace & with &amp;, the previous one will become &amp;lt;.
Yea, those are all the characters so it's fine.
ItWorks.png
It's not pretty but it works...
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 »

kyriakos876 wrote: November 4th, 2018, 7:15 pm Oh okay, so I can't put it all in the same... Kinda makes sense because if you replace < with &lt; and then if you replace & with &amp;, the previous one will become &amp;lt;.
Yea, those are all the characters so it's fine.
ItWorks.png

It's not pretty but it works...
You could write a function that you call and pass the string to, rather than repeating that all those times.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

jsmorley wrote: November 4th, 2018, 9:22 pm You could write a function that you call and pass the string to, rather than repeating that all those times.
Ah yes.... I will do that.
Also, I found a way to keep showing the notification in the ActionCenter without the user's innervation, but it writes a registry value. Would that be considered hacking and go against Rainmeter's "non-existing-rules" or something?
At the moment, I can give the user the option to keep the notification showing or to not keep it showing, as well as just keep it showing without them being able to choose anything...

So we could have an option like chrome has when you install it first time:
"Would you like chrome to show notifications?"
This includes them staying in the action center.
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 »

kyriakos876 wrote: November 4th, 2018, 10:13 pm Ah yes.... I will do that.
Also, I found a way to keep showing the notification in the ActionCenter without the user's innervation, but it writes a registry value. Would that be considered hacking and go against Rainmeter's "non-existing-rules" or something?
At the moment, I can give the user the option to keep the notification showing or to not keep it showing, as well as just keep it showing without them being able to choose anything...

So we could have an option like chrome has when you install it first time:
"Would you like chrome to show notifications?"
This includes them staying in the action center.
Kind of up to you, but our approach is to never write the the registry with skins. Nothing hard and fast about that, but it does break the "spirit of the law" when a user installs as "portable".
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

jsmorley wrote: November 4th, 2018, 10:38 pm Kind of up to you, but our approach is to never write the the registry with skins. Nothing hard and fast about that, but it does break the "spirit of the law" when a user installs as "portable".
So, no writting the registry. I'll try and find another way, though I'm pretty sure that it's either that or including the notification API toast in the Rainmeters source code, which I don't know how it would behave in anything other than Windows 10. ( But I think even then, the user will get a prompt asking whether they want Rainmeter to show notifications or not, including staying in the action center)
The obvious solution is to notify the user how to manually activate this option as you displayed in the pictures above
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 »

kyriakos876 wrote: November 4th, 2018, 10:53 pm So, no writting the registry. I'll try and find another way, though I'm pretty sure that it's either that or including the notification API toast in the Rainmeters source code, which I don't know how it would behave in anything other than Windows 10. ( But I think even then, the user will get a prompt asking whether they want Rainmeter to show notifications or not, including staying in the action center)
The obvious solution is to notify the user how to manually activate this option as you displayed in the pictures above
Yeah, that leaves things up to the user, which we prefer.
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA
Contact:

Re: Windows Notification Toaster

Post by raiguard »

Anyone have an idea as to why the Rainmeter notification is dimmed, while others are not?
2018-11-04 16_29_47-Window.png
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

raiguard wrote: November 5th, 2018, 8:39 pm Anyone have an idea as to why the Rainmeter notification is dimmed, while others are not?

2018-11-04 16_29_47-Window.png
Does it stay like that or did you caught it on the fade-in / fade-out animation?
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 5th, 2018, 9:23 pm Does it stay like that or did you caught it on the fade-in / fade-out animation?
It stays like this forever.
Post Reply