It is currently March 29th, 2024, 2:23 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

Re: Windows Notification Toaster

Post by kyriakos876 »

raiguard wrote: November 5th, 2018, 9:38 pm It stays like this forever.
Try a restart maybe? I've never gotten this behavior...
User avatar
raiguard
Posts: 660
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: Windows Notification Toaster

Post by raiguard »

kyriakos876 wrote: November 5th, 2018, 9:43 pm Try a restart maybe? I've never gotten this behavior...
No luck...
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
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, 9:49 pmNo luck...
Try changing the 6th lιne of the ps1 script to:

Code: Select all

$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
so that it runs with powershell instead of rainmeter, and if the issue persists.
User avatar
khanhas
Posts: 40
Joined: October 26th, 2016, 5:00 pm

Re: Windows Notification Toaster

Post by khanhas »

Since you uses Powershell to trigger notification, I think you can use PowershellRM to do it natively, less overhead and take full advantage of Powershell utilities.
PowershellRM has integration with Rainmeter API so you can get Rainmeter variable value natively rather than using lua to find and replace.
I made some changes with your PS script to show how it works

Code: Select all

[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
Add-Type -AssemblyName System.Web -IgnoreWarnings

$app = '{6D809377-6AF0-444B-8957-A3773F02200E}\Rainmeter\Rainmeter.exe'
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)

$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument

function EncodeVar {
  param([string]$name)
  $variableValue = $RmAPI.VariableStr($name)
  return [System.Web.HttpUtility]::HtmlEncode($variableValue)
}

function ToastIt {
  $TitleVar = EncodeVar('NotificationTitle')
  $ContextVar = EncodeVar('NotificationContext')
  $HeroImageVar = EncodeVar('NotificationTopImage')
  $appLogoOverrideVar = EncodeVar('NotificationIcon')
  $ButtonNameVar = EncodeVar('NotificationButtonName')
  $ButtonActionVar = EncodeVar('NotificationButtonAction')

  [xml]$ToastTemplate = @"
<toast launch="app-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>$TitleVar</text>
      <text>$ContextVar</text>
      <image placement="hero" src="$HeroImageVar"/>
      <image placement="appLogoOverride" hint-crop="circle" src="$appLogoOverrideVar"/>
    </binding>
  </visual>
  <actions>
    <action content="$ButtonNameVar" arguments="$ButtonActionVar" activationType="protocol"/>
  </actions>
</toast>
"@

  $ToastXml.LoadXml($ToastTemplate.OuterXml)
  $notify.Show($ToastXml)
}
Basically, I put creating XML template and notify method into a function called ToastIt.
In that function, I get and encode Rainmeter variable value with $RmAPI.VariableStr from PowershellRM and HtmlEncode from System.Web assembly, so we don't need Lua script to it for us or require users to encode by themeselves anymore.
We can now Show notification instantly after.
In skin INI, just simple use bang !CommandMeasure PSRM "ToastIt" to call ToastIt function we set up
You also can !SetVariable to change title/context/icon and toast new notification info on the fly without refreshing skin.
I packed new script and PowershellRM plugin here if you're interested in:
WindowSNotificationToaster_PSRM_1.0.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Windows Notification Toaster

Post by ikarus1969 »

@khanhas:

when i install your rmskin, i get a system-error "FileNotFound" for the plugin "PowershellRM".

At this place i use the portable version of Rainmeter. The rmskin correctly installs the plugin in the plugins directory of my portable version.

The gitHub-page of your plugin indicates ("...install the plugin in %appdata%\Rainmeter\Plugins), but that's not the place in a portable install.

Can this be the reason for the error?
Screenshot #1 Rainmeter crash.jpg
Screenshot #2 Rainmeter crash.jpg
Screenshot #3 Rainmeter crash.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Windows Notification Toaster

Post by kyriakos876 »

khanhas wrote: November 6th, 2018, 6:34 am Since you uses Powershell to trigger notification, I think you can use PowershellRM to do it natively, less overhead and take full advantage of Powershell utilities.
PowershellRM has integration with Rainmeter API so you can get Rainmeter variable value natively rather than using lua to find and replace.
I've made some improvements to the powershell script including using powershells functions to set the variables. This is my first time working with powershell scripts and XML so it'll get some trial and error to get to a simple and easy to use result. I will try the plugin to see if it helps. Though if what ikarus said above is true I won't be using it until the possibly location related issue has been resolved. Thanks!
I will upload the updated skin when I've fixed something's the need fixing :)
User avatar
khanhas
Posts: 40
Joined: October 26th, 2016, 5:00 pm

Re: Windows Notification Toaster

Post by khanhas »

@ikarus1969
Can you confirm that your Windows 7 has at least Powershell version 5.1?
1. Open up Powershell terminal
2. Run $psversiontable
Correct result should be: https://i.imgur.com/P6aCmr2.png

3. If you have any version lower than 5, try install this and restart: https://www.microsoft.com/en-us/download/details.aspx?id=54616
4. Hope it works out for you
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Windows Notification Toaster

Post by ikarus1969 »

O man....it's the desktop at the office and we have version 2.0 (!) of powershell installed...(no chance to install any newer version)
I guess i have to wait until i'm home where everything is up-to-date.

Thank's for caring!
Screenshot Rainmeter PS Version.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
khanhas
Posts: 40
Joined: October 26th, 2016, 5:00 pm

Re: Windows Notification Toaster

Post by khanhas »

I don't know if I get it right, but by the look of your window, I guess you're using Windows 7.
So upgrading Powershell might be resolve the problem but you won't able to use this skin since notification toast is Windows 10 only feature.
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Windows Notification Toaster

Post by ikarus1969 »

khanhas wrote: November 6th, 2018, 12:08 pm I don't know if I get it right, but by the look of your window, I guess you're using Windows 7.
So upgrading Powershell might be resolve the problem but you won't able to use this skin since notification toast is Windows 10 only feature.
Yes, you're right; i'm on Windows 7 here at the office.
So 2 version-problems here: powershell and windows