Comments (11)
There is! I (finally) realised this while working on v0.6.0 but didn't have a chance to document it before release.
Unfortunately at the moment it's not possible to do this using only the New-BurntToastNotification
function, so you need to dive into the more advanced functions:
$Text1 = New-BTText -Content 'Google!'
$Text2 = New-BTText -Content 'Clicking this will open Google.'
$Binding1 = New-BTBinding -Children $Text1, $Text2
$Visual1 = New-BTVisual -BindingGeneric $Binding1
$Content1 = New-BTContent -Visual $Visual1 -Launch 'https://google.com' -ActivationType Protocol
Submit-BTNotification -Content $Content1
The key to this is on the New-NTContent
function: defining the -Launch
as the url/uri/path you want to open, and setting the -ActivationType
to Protocol.
Note that if you have buttons or progress bars or anything else on there, the clickable area is only the pictures/main text (clicking to progress bar is a deadzone, from memory)
I'll hopefully figure out a way to make this easier in the next release.
from burnttoast.
I know this is an old issue, but it deserves a wrap up with links to relevant info.
First, Custom URIs/Protocol Handlers: @adamdriscoll does an awesome job of showing this in this Module Monday video on BurntToast. I've also demo'ed it for the Research Triangle PowerShell User Group, the sample code for that is on their repo.
Second, ACTIONABLE TOASTS!
It's now possible to run any code via a toast notification action. This does require PowerShell 7.1 or above and BurntToast 0.8.0.
This blog post shows it in action, though with v0.8.0 it's a lot easier to take advantage of this via some new parameters on New-BurntToastNotification and Submit-BTNotification. Documentation for this is coming soon, for now check out the end of this live stream.
from burnttoast.
An other way could be to create a new handler for a internal protocol.
$Content1 = New-BTContent -Visual $Visual1 -Launch 'BurntToast://my-data' -ActivationType Protocol
But this tricks dosen't work with complex toast:
<toast duration="5">
<visual>
<binding template="ToastGeneric">
<text>This is a test</text>
<text />
<text>This more testing</text>
<text>RAWR</text>
<image src="C:\Users\King\Documents\GitHub\BurntToast\Media\BurntToast.png" hint-removeMargin="false" />
</binding>
</visual>
<audio src="ms-winsoundevent:Notification.SMS" />
<actions>
<input id="snoozeTime" type="selection" defaultInput="3">
<selection id="1" content="1 Minutes" />
<selection id="2" content="2 Minutes" />
<selection id="3" content="3 Minutes" />
<selection id="4" content="4 Minutes" />
<selection id="5" content="5 Minutes" />
</input>
<action content="" arguments="snooze" activationType="system" />
<action content="" arguments="dismiss" activationType="system" />
</actions>
</toast>
from burnttoast.
@Windos
is there a way to call some function instead of launch browser?
In my case i want to focus a proccess by id.
Set-ForegroundWindow (Get-Process -id $procid).MainWindowHandle
from burnttoast.
There is a bypass with a small dll.
See: https://deletethis.net/dave/2016-06/WinRT+Toast+from+PowerShell
May be it's possible to convert the C# dll in powershell script
from burnttoast.
Thanks for that link, very helpful. I'd considered bundling a compiled exe to handle this early on in the project and decided against it at the time.
I wonder if, like you say, it'd be possible to get this working in native PowerShell. We're working with PS5 here... so possibly PowerShell classes could be used.
As an aside, this issue prompted a blog post if anyone is interested.
from burnttoast.
I'll do some testing tonight, but thinking through it now: not directly because the string that's included as the action on a button isn't running inside PowerShell.
However, in theory anything you can do from the 'Run' dialogue should work where, so you might be able to start a PowerShell.exe instance with the function you want to run as an argument.
from burnttoast.
However, in theory anything you can do from the 'Run' dialogue should work where, so you might be able to start a PowerShell.exe instance with the function you want to run as an argument.
May I ask how would you launch an exe from a toast ? From my testing I could only launch files other than executables with that -launch:"" argument. Launching a .txt file opens the file in notepad, yet the exact path of notepad.exe didn't do the trick - Am I missing something there ?
Thanks in advance for your answer :)
from burnttoast.
Launching a .txt file opens the file in notepad, yet the exact path of notepad.exe didn't do the trick - Am I missing something there ?
If have tried a few things and the problem seems to correlate with what program you open the file with by default.
Say you insert the path of your test.ps1 into the launch parameter and execute the toast, the launch action will not be executed.
But if you choose the standard program to always open .ps1-files (notepad++.exe, in my case) via the 'open with'-dialoge, running your toast.ps1 will open the test.ps1 in notepad++.
However choosing powershell.exe to be the default program doesn't do the trick either for some reason.
It seems to me like something in the code forbids executables to be executed...?
from burnttoast.
You have to use a custom URI. There are several people who have found that this approach works. Check out the comments on this thread:
from burnttoast.
Thanks for the speedy answer.
But sadly I did not quite understand what to do to set up a custom URI. Looks like I'll have to invest some more time in the future
from burnttoast.
Related Issues (20)
- No alert sound on multiple machines, except on the first I installed to. HOT 3
- BurntToast -AppLogo does not accept valid UNC paths to WSL locations HOT 2
- Missing documentation on the ActivatedAction parameter on Submit-BTNotification function HOT 1
- empty AppLogo as default value HOT 6
- Doc: how to enable notifications HOT 2
- Typo in Example05? HOT 1
- Toast History access failure on PowerShell 7.2.1 HOT 2
- Provide a feature to read the content of currently displayed Toast Notifications HOT 4
- [Bug]: MethodInvocationException: Exception calling "Show" with "1" argument(s): "Access is denied. HOT 1
- [Bug]: Update-BTNotification not doing its job even when verbose shows no error. HOT 5
- Replace/Remove Shipped DLLs
- Allow variable names to be displayed in the toast notification HOT 1
- character limit notification text HOT 1
- New-BurntToastNotification Button Overflow Menu HOT 1
- icon and heroImage with http-URL HOT 1
- [Bug]: Basic test script does not work HOT 5
- [Bug]: Can't set button label with New-BTButton with Update-BTNotification HOT 2
- warn not to use Windows Store PowerShell
- Easy way to register Notification App (Name and Icon)
- Burnttoast-Problem:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from burnttoast.