Somebody know why this script works fine in Powershell_ISE but when running in the console doesn't seem to catch the click events?
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)#Remove any registered events related to notifications
#Define the icon for the system tray
#Display title of balloon window
#Type of balloon icon
#Make balloon tip visible when called
## Register a click event with action to take based on event
#Balloon message closed
#Call the balloon notification
The ISE is a Windows Forms application, so it is already set up to handle windows messages from the notify icon. PowerShell.exe, on the other hand, is a console application. While you can use some Windows Forms classes successfully from a console app, some things (such as the notify icon events, as you've discovered) don't work quite the same way. If you search the web for [b]NotifyIcon Console Application[/b], you'll get all sorts of results from C# programmers running into the same issue. The catch is that many of the solutions you'll find for this problem involve multiple threads, which are tricky to do properly in PowerShell.
You must be logged in to reply to this topic.