Notifications
Clear all
[Closed] Trigger Windows 10 Notification
Dec 22, 2020 4:00 am
Does anyone have a way to trigger a Windows 10 notification from max?
3 Replies
Dec 22, 2020 4:00 am
From Marc Auvigne
(
local PATH_TMP = GetDir #temp
File_Tmp = PATH_TMP + "\\Win10_Notification.ps1 "
local Title_Var = "3dsMaxNotification" --That the Title of the notification
--Type Here the message to send"
local MyMessage = ""
MyMessage += "Hello world"
--Powershell Script
Fn PowerShell_Builder FileTmp =
(
local MyPWS = ""
--Powershell Script
MyPWS = "[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")" +"\n"
MyPWS += "$icon = $args[0]" +"\n"
MyPWS += "$text = $args[2] -split \"``n\" -join \"`n\"" +"\n"
MyPWS += "$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon" +"\n"
MyPWS += "$objNotifyIcon.Icon = [System.Drawing.SystemIcons]::$icon" +"\n"
MyPWS += "$objNotifyIcon.BalloonTipIcon = \"None\"" +"\n"
MyPWS += "$objNotifyIcon.BalloonTipText = $text" +"\n"
MyPWS += "$objNotifyIcon.BalloonTipTitle = $args[1]" +"\n"
MyPWS += "$objNotifyIcon.Visible = $True" +"\n"
MyPWS += "$objNotifyIcon.ShowBalloonTip(10000)" +"\n"
--------------------------------------
--NOW GENERATE THE Powershell SCRIPT--
--------------------------------------
--create the script
--Acquire 3s max Temps Folder then Write the Script
local TempScript = FileTmp --Set the max file script name
fn existfile fname = (getfiles fname).count !=0 --Check if script already exist
if existfile(TempScript) do
(
deleteFile (TempScript) --If a old script exist delete it
format "an old residual script was delete...\n"
)
format (MyPWS) to:(local CreateScript = createfile(TempScript)) --Write the Script
Close CreateScript --Close the file to enable manipulations
format "The Script is successfully generated...\n\n"
)
PowerShell_Builder File_Tmp
--Type here the Cmd to execute for Windows 10 notification
local MyCmd = "powershell -executionpolicy bypass -file \"" + (File_Tmp as string) + "\" Information " + (Title_Var as string) + " \"" + (MyMessage as string) + "\""
--Execute the Cmd
Print "Execute CMD...."
DOSCommand MyCmd
deleteFile (File_Tmp)
)
Dec 22, 2020 4:00 am
This may also work. If so, it should be easier to work with and you also would get access to events.
(
NotifyIcon = dotnetobject "System.Windows.Forms.NotifyIcon"
NotifyIcon.BalloonTipTitle = "3ds Max Notification"
NotifyIcon.BalloonTipText = "Hello World"
NotifyIcon.Visible = true
/* Application Asterisk Error Exclamation Hand Information Question Shield Warning WinLogo */
NotifyIcon.Icon = (dotnetclass "System.Drawing.SystemIcons").Asterisk
fn BalloonTipClicked = messagebox "Balloon Clicked"
fn Click = NotifyIcon.Dispose()
--fn BalloonTipClosed = NotifyIcon.Dispose()
dotnet.addeventhandler NotifyIcon "BalloonTipClicked" BalloonTipClicked
dotnet.addeventhandler NotifyIcon "Click" Click
--dotnet.addeventhandler NotifyIcon "BalloonTipClosed" BalloonTipClosed
NotifyIcon.ShowBalloonTip 0
)