logo

How to Show Notifications with WinBalloons in Julia 📂Julia

How to Show Notifications with WinBalloons in Julia

Code

Julia — whatever you use it for — it can be convenient in many ways to receive a Windows notification when a task finishes or an error occurs. The following code defines a function balloon that displays a given text as a balloon (balloon tip) via PowerShell on Windows.

function balloon(msg = "julia error!")
    run(`powershell -command "[reflection.assembly]::loadwithpartialname('System.Windows.Forms') | Out-Null; \$n=new-object system.windows.forms.notifyicon; \$n.icon=[System.Drawing.SystemIcons]::Error; \$n.visible=\$true; \$n.showballoontip(5000,'알림','$msg',[system.windows.forms.tooltipicon]::Error); Start-Sleep -Seconds 5; \$n.dispose()"`)
    return nothing
end

When actually run, it works like this:

error

Fundamentally, because this approach uses PowerShell itself without relying on a package, you can add and extend functionality by searching for system.windows.forms.tooltipicon and reading the MS official documentation.

Alternative: Alert.jl

The method introduced so far avoids package dependencies but is limited to Windows. Alert.jl supports cross-platform operation, providing notifications regardless of the OS1.